--- loncom/publisher/loncfile.pm 2002/11/27 17:05:50 1.20 +++ loncom/publisher/loncfile.pm 2003/02/04 21:54:17 1.22 @@ -10,7 +10,7 @@ # # -# $Id: loncfile.pm,v 1.20 2002/11/27 17:05:50 albertel Exp $ +# $Id: loncfile.pm,v 1.22 2003/02/04 21:54:17 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -128,7 +128,7 @@ sub Debug { my $log = $r->log; my $message = shift; - # Put out the indicated message butonly if DEBUG is false. + # Put out the indicated message butonly if DEBUG is true. if ($DEBUG) { $log->debug($message); @@ -323,20 +323,24 @@ sub exists { my ($user, $domain, $dir, $file) = @_; # Create complete paths in publication and construction space. - - my $published = &PublicationPath($domain, $user, $dir, $file); - my $construct = &ConstructionPath($user, $dir, $file); + my $relativedir=$dir; + $relativedir=s|/home/\Q$user\E/public_html||; + my $published = &PublicationPath($domain, $user, $relativedir, $file); + my $construct = &ConstructionPath($user, $relativedir, $file); # If the resource exists in either space indicate this fact. # Note that the check for existence in resource space is stricter. my $result; + if ( -d $construct ) { + return 'Error: destination for operation is a directory.'; + } if ( -e $published) { - $result.='
Warning: target file exists, and has been published!
'; + $result.='Warning: target file exists, and has been published!
'; } elsif ( -e $construct) { - $result.='Warning: target file exists!
'; - } + $result.='Warning: target file exists!
'; + } return $result; @@ -409,7 +413,7 @@ sub CloseForm1 { &Debug($request, "Cancel url is: ".$cancelurl); $request->print(''); $request->print(''); + '" method="GET">');
}
@@ -492,7 +496,12 @@ sub Rename1 {
if($ENV{'form.newfilename'}) {
my $newfilename = $ENV{'form.newfilename'};
$request->print(&checksuffix($filename, $newfilename));
- $request->print(&exists($user, $domain, $dir, $newfilename));
+ my $return=&exists($user, $domain, $dir, $newfilename);
+ $request->print($return);
+ if ($return =~/^Error:/) {
+ $request->print('
Cancel');
+ return;
+ }
my $dest=&SimplifyDir($dir,$newfilename);
$request->print('Cancel');
+ return;
+ }
my $dest=&SimplifyDir($dir,$newfilename);
$request->print('print('
File exists.
'); + } + else { + $request->print('Make new file '.$newfilename.'?
'); + my $dest=&MakeFinalUrl($request,$fullpath); + &Debug($request, "Cancel url is: ".$cancelurl); + &Debug($request, "Dest url is: ".$dest); + $request->print(''); + $request->print(''); + $request->print(''); + } +} + +=pod + =item phaseone($r, $fn, $uname, $udom) Peforms phase one processing of the request. In phase one, error messages @@ -751,8 +843,20 @@ sub phaseone { } } elsif ($ENV{'form.action'} eq 'newdir') { &NewDir1($r, $uname, $dir, $ENV{'form.newfilename'}); + } elsif ($ENV{'form.action'} eq 'newfile' || + $ENV{'form.action'} eq 'newhtmlfile' || + $ENV{'form.action'} eq 'newproblemfile') { + if($ENV{'form.newfilename'}) { + my $newfilename = $ENV{'form.newfilename'}; + if (!defined($dir)) { + $fn=~m:(.*)/:; + $dir=$1; + } + &NewFile1($r, $uname, $udom, $dir, $fn, $newfilename); + }else { + $r->print('No new filename specified.
'); + } } - } =pod @@ -1045,19 +1149,24 @@ sub phasetwo { # Substitute for priv for the first home in $dir to get our # construction space path. # + $dest=&MakeFinalUrl($r,$dest); + + $r->print('Unknown Action