--- loncom/publisher/loncfile.pm 2003/03/10 18:34:14 1.29
+++ loncom/publisher/loncfile.pm 2008/05/27 17:33:28 1.89
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.29 2003/03/10 18:34:14 albertel Exp $
+# $Id: loncfile.pm,v 1.89 2008/05/27 17:33:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,27 +33,6 @@
#
# http://www.lon-capa.org/
#
-#
-# (Handler to retrieve an old version of a file
-#
-# (Publication Handler
-#
-# (TeX Content Handler
-#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer
-# 03/23 Guy Albertelli
-# 03/24,03/29 Gerd Kortemeyer)
-#
-# 03/31,04/03,05/02,05/09,06/23,06/24 Gerd Kortemeyer)
-#
-# 06/23 Gerd Kortemeyer
-# 05/07/02 Ron Fox:
-# - Added Debug log output so that I can trace what the heck this
-# undocumented thingy does.
-# 05/28/02 Ron Fox:
-# - Started putting in pod in standard format.
=pod
=head1 NAME
@@ -90,8 +69,11 @@ use File::Copy;
use HTML::Entities();
use Apache::Constants qw(:common :http :methods);
use Apache::loncacc;
-use Apache::Log ();
use Apache::lonnet;
+use Apache::loncommon();
+use Apache::lonlocal;
+use LONCAPA qw(:DEFAULT :match);
+
my $DEBUG=0;
my $r; # Needs to be global for some stuff RF.
@@ -120,18 +102,22 @@ my $r; # Needs to be global for some
=cut
sub Debug {
-
- # Marshall the parameters.
-
- my $r = shift;
- my $log = $r->log;
- my $message = shift;
-
- # Put out the indicated message butonly if DEBUG is true.
-
- if ($DEBUG) {
- $log->debug($message);
- }
+ # Put out the indicated message butonly if DEBUG is true.
+ if ($DEBUG) {
+ my ($r,$message) = @_;
+ $r->log_reason($message);
+ }
+}
+
+sub done {
+ my ($url)=@_;
+ my $done=&mt("Done");
+ return(< '.&mt('Error: destination for operation is an existing directory.').' Warning: target file exists, and has been published! Warning: target file exists! '.&mt('Warning: target file exists, and has been published!').' '.&mt("Warning: a published $published_type of this name exists.").' '.&mt("Error: a published $published_type of this name exists.").' '.&mt('Warning: target file exists!').' Warning: change of MIME type! '.&mt('Warning: change of MIME type!').' ".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"'.&display($newpath).'"')." ".&mt('Invalid characters in requested name have been removed.')." Rename '.$filename.
- ' '.$action.' '.&display($fn).
+ '
(name).(number).(extension) not allowed.
Removing the .number. from requested filename.',&display($dest))
+ .'');
+ $dest =~ s/\.(\d+)(\.\w+)$/$2/;
+ }
+ if ($foundbad) {
+ $request->print("Done
');
+ my ($request, $user, $fn) = @_;
+ $request->print(&done(&url($fn)));
}
=pod
@@ -483,53 +485,73 @@ new filename relative to the current dir
=cut
sub Rename1 {
- my ($request, $filename, $user, $domain, $dir) = @_;
- &Debug($request, "Username - ".$user." filename: ".$filename."\n");
- my $conspace = $filename;
-
- my $cancelurl = "/priv/".$filename;
- $cancelurl =~ s/\/home\///;
- $cancelurl =~ s/\/public_html//;
-
- if(-e $conspace) {
- if($ENV{'form.newfilename'}) {
- my $newfilename = $ENV{'form.newfilename'};
+ my ($request, $user, $domain, $fn, $newfilename, $style) = @_;
+
+ if(-e $fn) {
+ if($newfilename) {
+ # is dest a dir
+ if ($style eq 'move') {
+ if (-d $newfilename) {
+ if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
+ }
+ }
if ($newfilename =~ m|/[^\.]+$|) {
- #no extension add on orignal extension
- if ($filename =~ m|/[^\.]*\.([^\.]+)$|) {
+ #no extension add on original extension
+ if ($fn =~ m|/[^\.]*\.([^\.]+)$|) {
$newfilename.='.'.$1;
}
}
- $request->print(&checksuffix($filename, $newfilename));
+ $request->print(&checksuffix($fn, $newfilename));
#renaming a dir, delete the trailing /
- #remove last element for current dir
- if ($filename =~ m|/$|) {
- $filename =~ s|/$||;
- $dir =~ s|/[^/]*$||;
+ #remove second to last element for current dir
+ if (-d $fn) {
+ $newfilename=~/\.(\w+)$/;
+ if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
+ $request->print('
'.
+ &mt('Cannot change MIME type of a directory').
+ ''.
+ '
'.&mt('Cancel').'');
+ return;
+ }
+ $newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/;
}
- my $return=&exists($user, $domain, $dir, $newfilename);
+ $newfilename=~s://+:/:g; # remove duplicate /
+ while ($newfilename=~m:/\.\./:) {
+ $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
+ }
+ my ($type, $return)=&exists($user, $domain, $newfilename);
$request->print($return);
- if ($return =~/^Error:/) {
- $request->print('
Cancel');
+ if ($type eq 'error') {
+ $request->print('
'.&mt('Cancel').'');
+ return;
+ }
+ unless (&obsolete_unpub($user,$domain,$fn)) {
+ $request->print(''.&mt('Cannot rename or move non-obsolete published file').'
'.
+ '
'.&mt('Cancel').'');
return;
}
- my $dest=&SimplifyDir($dir,$newfilename);
+ my $action;
+ if ($style eq 'rename') {
+ $action=&mt('Rename');
+ } else {
+ $action=&mt('Move');
+ }
$request->print('
to '.
- $dest.'?
to '.&display($newfilename).'?
No new filename specified
'); + $request->print(''.&mt('No new filename specified.').'
'); return; } } else { - $request->print('No such File
'); + $request->print(''.&mt('No such file').': '.&display($fn).'
'); return; } } + =pod =item Delete1 @@ -541,35 +563,44 @@ Parameters: =over 4 -=item $request - Apache Request Object [in] request object for the current +=item $request - Apache Request Object [in] request object for the current request. -=item $user - string [in] Name of session user. +=item $user - string [in] Name of the user initiating the request. +=item $domain - string [in] Domain the initiating user is logged in as -=item $filename - string [in] Name fo the file to be deleted: - Filename is the full filesystem path to the file. +=item $filename - string [in] Source filename. =back =cut sub Delete1 { - my ($request, $user, $filename) = @_; - - my $cancelurl = '/priv/'.$filename; - $cancelurl =~ s/\/home\///; - $cancelurl =~ s/\/public_html//; - + my ($request, $user, $domain, $fn) = @_; - if( -e $filename) { - $request->print(''); - $request->print('Delete '.$filename.'?
'); - &CloseForm1($request, $cancelurl); - } else { - $request->print('No Such file: '.$filename.'
'); - } + if( -e $fn) { + $request->print(''); + if (-d $fn) { + unless (&empty_directory($fn,'Delete1')) { + $request->print(''.&mt('Delete').' '.&display($fn).'?
'); + &CloseForm1($request, $fn); + } else { + $request->print(''.&mt('No such file').': '.&display($fn).'
'); + } } =pod @@ -591,9 +622,7 @@ Parameters: =item $domain - string [in] Domain the initiating user is logged in as -=item $dir - string [in] Directory path. - -=item $filename - string [in] Source filename. +=item $fn - string [in] Source filename. =item $newfilename-string [in] Destination filename. @@ -602,58 +631,36 @@ Parameters: =cut sub Copy1 { - my ($request, $user, $domain, $dir, $filename, $newfilename) = @_; + my ($request, $user, $domain, $fn, $newfilename) = @_; - my $cancelurl = "/priv/".$filename; - $cancelurl =~ s/\/home\///; - $cancelurl =~ s/\/public_html//; - - - if(-e $filename) { - $request->print(&checksuffix($filename,$newfilename)); - my $return=&exists($user, $domain, $dir, $newfilename); - $request->print($return); - if ($return =~/^Error:/) { - $request->print(''.&mt('Copy').' '.&display($fn).'
to '.
+ &display($newfilename).'?
'.&mt('No such file').': '.&display($fn).'
'); } - my $dest=&SimplifyDir($dir,$newfilename); - $request->print('Copy '.$filename.'
to '.
- ''.$dest.'?
No such file '.$filename.'
'); - } -} - -=pod - -=item SimplifyDir - - Removes all extra / and all .. references - -Parameters: - -=over 4 - -=item $dir - string [in] a directory name - -=item $file - string [in] a file reference relative to $dir - -=back - -Results: the concatenated path. - -=cut - -sub SimplifyDir { - my ($dir,$file) = @_; - my $location = $dir. '/'.$file; - $location=~s://+:/:g; # remove duplicate / - while ($location=~m:/\.\./:) {$location=~s:/[^/]+/\.\./:/:g;}#remove dir/.. - return $location; } =pod @@ -673,7 +680,9 @@ Parameters: =item $username - Name of the user that is requesting the directory creation. -=item $path - current directory relative to construction space. +=item $domain - Domain user is in + +=item $fn - source file. =item $newdir - Name of the directory to be created; path relative to the top level of construction space. @@ -693,27 +702,36 @@ causes the newdir operation to transitio =cut -sub NewDir1 -{ - my ($request, $username, $path, $newdir) = @_; - - my $fullpath = '/home/'.$username.'/public_html/'. - $path.'/'.$newdir; - - my $cancelurl = '/priv/'.$username.'/'.$path; - - &Debug($request, "Full path is : ".$fullpath); - - if(-e $fullpath) { - $request->print('Directory exists.
'); - } - else { - $request->print('Make new directory '. - $path."/".$newdir.'?
'); - &CloseForm1($request, $cancelurl); +sub NewDir1 { + my ($request, $username, $domain, $fn, $newfilename, $mode) = @_; - } + my ($type, $result)=&exists($username,$domain,$newfilename,'directory'); + $request->print($result); + if ($type eq 'error') { + $request->print(''); + } else { + if ($mode eq 'testbank') { + $request->print(''); + } elsif ($mode eq 'imsimport') { + $request->print(''); + } + $request->print(''.&mt('Make new directory').' '. + &display($newfilename).'?
'); + &CloseForm1($request, $fn); + } +} + + +sub Decompress1 { + my ($request, $user, $domain, $fn) = @_; + if( -e $fn) { + $request->print(''); + $request->print(''.&mt('Decompress').' '.&display($fn).'?
'); + &CloseForm1($request, $fn); + } else { + $request->print(''.&mt('No such file').': '.&display($fn).'
'); + } } =pod @@ -737,7 +755,7 @@ Parameters: =item $domain - Name of the domain of the user -=item $dir - current absolute diretory +=item $fn - Source file name =item $newfilename - Name of the file to be created; no path information @@ -749,52 +767,52 @@ Side Effects: =item 2 new forms are displayed. Clicking on the confirmation button causes the browser to attempt to load the specfied URL, allowing the -proper handler to take care of file creation. There is also a Cancle +proper handler to take care of file creation. There is also a Cancel button which returns you to the driectory listing you came from =back =cut - sub NewFile1 { - my ($request, $user, $domain, $dir, $newfilename) = @_; - - &Debug($request, "Dir is : ".$dir); - &Debug($request, "Newfile is : ".$newfilename); - - my $cancelurl = "/priv/".$dir; - $cancelurl =~ s/\/home\///; - $cancelurl =~ s/\/public_html//; + my ($request, $user, $domain, $fn, $newfilename) = @_; - if ($ENV{'form.action'} =~ /new(.+)file/) { + if ($env{'form.action'} =~ /new(.+)file/) { my $extension=$1; + + ##Informs User (name).(number).(extension) not allowed + if($newfilename =~ /\.(\d+)\.(\w+)$/){ + $r->print(''.$newfilename. + ' - '.&mt('Bad Filename').'File exists.
'); - } - else { - $request->print('Make new file '.$dir.'/'.$newfilename.'?
'); - my $dest=&MakeFinalUrl($request,$fullpath); - &Debug($request, "Cancel url is: ".$cancelurl); - &Debug($request, "Dest url is: ".$dest); + my ($type, $result)=&exists($user,$domain,$newfilename); + $request->print($result); + if ($type eq 'error') { $request->print(''); - $request->print(''); - $request->print(''); + } else { + + $request->print(''.&mt('Make new file').' '.&display($newfilename).'?
'); + $request->print(''); + $request->print(''); + $request->print(''); } } @@ -827,56 +845,54 @@ performed and reported to the user. =cut sub phaseone { - my ($r,$fn,$uname,$udom)=@_; - - $fn=~m:(.*)/([^/]+)\.(\w+)$:; - my $dir=$1; - my $main=$2; - my $suffix=$3; - - # my $conspace=ConstructionPathFromRelative($uname, $fn); - + my ($r,$fn,$uname,$udom)=@_; - $r->print(''); - } - } 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' || - $ENV{'form.action'} eq 'newpagefile' || - $ENV{'form.action'} eq 'newsequencefile') { - if($ENV{'form.newfilename'}) { - my $newfilename = $ENV{'form.newfilename'}; - if (!defined($dir)) { - $fn=~m:(.*)/:; - $dir=$1; - } - &NewFile1($r, $uname, $udom, $dir, $newfilename); - } else { - $r->print('No new filename specified.
'); - } - } + if ($env{'form.action'} eq 'rename') { + &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename'); + } elsif ($env{'form.action'} eq 'move') { + &Rename1($r, $uname, $udom, $fn, $newfilename, 'move'); + } elsif ($env{'form.action'} eq 'delete') { + &Delete1($r, $uname, $udom, $fn); + } elsif ($env{'form.action'} eq 'decompress') { + &Decompress1($r, $uname, $udom, $fn); + } elsif ($env{'form.action'} eq 'copy') { + if($newfilename) { + &Copy1($r, $uname, $udom, $fn, $newfilename); + } else { + $r->print(''.&mt('No new filename specified.').'
'); + } + } elsif ($env{'form.action'} eq 'newdir') { + my $mode = ''; + if (exists($env{'form.callingmode'}) ) { + $mode = $env{'form.callingmode'}; + } + &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); + } elsif ($env{'form.action'} eq 'newfile' || + $env{'form.action'} eq 'newhtmlfile' || + $env{'form.action'} eq 'newproblemfile' || + $env{'form.action'} eq 'newpagefile' || + $env{'form.action'} eq 'newsequencefile' || + $env{'form.action'} eq 'newrightsfile' || + $env{'form.action'} eq 'newstyfile' || + $env{'form.action'} eq 'newtaskfile' || + $env{'form.action'} eq 'newlibraryfile' || + $env{'form.action'} eq 'Select Action') { + my $empty=&mt('Type Name Here'); + if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { + &NewFile1($r, $uname, $udom, $fn, $newfilename); + } else { + $r->print(''.&mt('No new filename specified.').'
'); + } + } } =pod @@ -915,37 +931,58 @@ Returns: sub Rename2 { - my ($request, $user, $directory, $oldfile, $newfile) = @_; + my ($request, $user, $directory, $oldfile, $newfile) = @_; - &Debug($request, "Rename2 directory: ".$directory." old file: ".$oldfile. - " new file ".$newfile."\n"); - &Debug($request, "Target is: ".$directory.'/'. - $newfile); - - if(-e $oldfile) { - my $dest; - - if ($oldfile =~ m|/$|) { - #renaming a dir - $oldfile =~ s|/$||; - $dest=$directory; - $dest=~s|(/)([^/]*)$|$1|; - $dest.='/'.$newfile; - } else { - $dest=$directory.'/'.$newfile; - } - - unless(rename($oldfile,$dest)) { - $request->print('Error: '.$!.''); - return 0; - } else {} - } else { - $request->print("No such file: /home".$user.'/public_html'. - $oldfile.'
'); - return 0; - } - return 1; + &Debug($request, "Rename2 directory: ".$directory." old file: ".$oldfile. + " new file ".$newfile."\n"); + &Debug($request, "Target is: ".$directory.'/'. + $newfile); + if (-e $oldfile) { + + my $oRN=$oldfile; + my $nRN=$newfile; + unless (rename($oldfile,$newfile)) { + $request->print(''.&mt('Error').': '.$!.''); + return 0; + } + ## If old name.(extension) exits, move under new name. + ## If it doesn't exist and a new.(extension) exists + ## delete it (only concern when renaming over files) + my $tmp1=$oRN.'.meta'; + my $tmp2=$nRN.'.meta'; + if(-e $tmp1){ + unless(rename($tmp1,$tmp2)){ } + } elsif(-e $tmp2){ + unlink $tmp2; + } + $tmp1=$oRN.'.save'; + $tmp2=$nRN.'.save'; + if(-e $tmp1){ + unless(rename($tmp1,$tmp2)){ } + } elsif(-e $tmp2){ + unlink $tmp2; + } + $tmp1=$oRN.'.log'; + $tmp2=$nRN.'.log'; + if(-e $tmp1){ + unless(rename($tmp1,$tmp2)){ } + } elsif(-e $tmp2){ + unlink $tmp2; + } + $tmp1=$oRN.'.bak'; + $tmp2=$nRN.'.bak'; + if(-e $tmp1){ + unless(rename($tmp1,$tmp2)){ } + } elsif(-e $tmp2){ + unlink $tmp2; + } + } else { + $request->print("".&mt('No such file').": ".&display($oldfile).'
'); + return 0; + } + return 1; } + =pod =item Delete2($request, $user, $filename) @@ -976,18 +1013,34 @@ Returns: =cut sub Delete2 { - my ($request, $user, $filename) = @_; - - if(-e $filename) { - unless(unlink($filename)) { - $request->print('Error: '.$!.''); - return 0; + my ($request, $user, $filename) = @_; + if (-d $filename) { + unless (&empty_directory($filename,'Delete2')) { + $request->print(''.&mt('Error: Directory Non Empty').''); + return 0; + } else { + if(-e $filename) { + unless(rmdir($filename)) { + $request->print(''.&mt('Error').': '.$!.''); + return 0; + } + } else { + $request->print(''.&mt('No such file').'.
'); + return 0; + } + } + } else { + if(-e $filename) { + unless(unlink($filename)) { + $request->print(''.&mt('Error').': '.$!.''); + return 0; + } + } else { + $request->print(''.&mt('No such file').'.
'); + return 0; + } } - } else { - $request->print('No such file.
print(''.&mt('Warning').': '.&mt('Name of new file is the same as name of old file').' - '.&mt('no action taken').'.'); + return 1; + } unless (copy($oldfile, $newfile)) { - $request->print(' copy Error: '.$!.''); + $request->print(''.&mt('copy Error').': '.$!.''); + return 0; + } elsif (!chmod(0660, $newfile)) { + $request->print(''.&mt('chmod error').': '.$!.''); + return 0; + } elsif (-e $oldfile.'.meta' && + !copy($oldfile.'.meta', $newfile.'.meta') && + !chmod(0660, $newfile.'.meta')) { + $request->print(''.&mt('copy metadata error'). + ': '.$!.''); return 0; } else { - unless (chmod(0660, $newfile)) { - $request->print(' chmod error: '.$!.''); - return 0; - } return 1; } } else { - $request->print('No such file
'); + $request->print(''.&mt('No such file').'
'); return 0; } return 1; } + =pod =item NewDir2($request, $user, $newdirectory) @@ -1061,17 +1124,28 @@ Returns 0 - failure 1 - success. =cut sub NewDir2 { - my ($request, $user, $newdirectory) = @_; + my ($request, $user, $newdirectory) = @_; - unless(mkdir($newdirectory, 02770)) { - $request->print('Error: '.$!.''); - return 0; - } - unless(chmod(02770, ($newdirectory))) { - $request->print(' Error: '.$!.''); - return 0; - } - return 1; + unless(mkdir($newdirectory, 02770)) { + $request->print(''.&mt('Error').': '.$!.''); + return 0; + } + unless(chmod(02770, ($newdirectory))) { + $request->print(''.&mt('Error').': '.$!.''); + return 0; + } + return 1; +} + +sub decompress2 { + my ($r, $user, $dir, $file) = @_; + &Apache::lonnet::appenv({'cgi.file' => $file}); + &Apache::lonnet::appenv({'cgi.dir' => $dir}); + my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl'); + $r->print($result); + &Apache::lonnet::delenv('cgi.file'); + &Apache::lonnet::delenv('cgi.dir'); + return 1; } =pod @@ -1111,206 +1185,223 @@ sub phasetwo { &Debug($r, "loncfile - Entering phase 2 for $fn"); - # Break down the file into it's component pieces. + # Break down the file into its component pieces. my $dir; # Directory path my $main; # Filename. my $suffix; # Extension. - - if ($fn=~m:(.*)/([^/]+)\.(\w+)$:) { + if ($fn=~m:(.*)/([^/]+):) { $dir=$1; # Directory path $main=$2; # Filename. - $suffix=$3; # Extension. } - - my $dest; # On success this is where we'll go. - - &Debug($r, - "loncfile::phase2 dir = $dir main = $main suffix = $suffix"); - &Debug($r, - " newfilename = ".$ENV{'form.newfilename'}); + if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions + $suffix=$1; #This is the actually filename extension if it exists + $main=~s/\.\w+$//; #strip the extension + } + my $dest; # + my $dest_dir; # On success this is where we'll go. + my $disp_newname; # + my $dest_newname; # + &Debug($r,"loncfile::phase2 dir = $dir main = $main suffix = $suffix"); + &Debug($r," newfilename = ".$env{'form.newfilename'}); my $conspace=$fn; - &Debug($r, - "loncfile::phase2 Full construction space name: $conspace"); + &Debug($r,"loncfile::phase2 Full construction space name: $conspace"); - &Debug($r, - "loncfie::phase2 action is $ENV{'form.action'}"); + &Debug($r,"loncfie::phase2 action is $env{'form.action'}"); # Select the appropriate processing sub. - - if ($ENV{'form.action'} eq 'rename') { # Rename. - if($ENV{'form.newfilename'}) { + if ($env{'form.action'} eq 'decompress') { + $main .= '.'.$suffix; + if(!&decompress2($r, $uname, $dir, $main)) { + return ; + } + $dest = $dir."/."; + } elsif ($env{'form.action'} eq 'rename' || + $env{'form.action'} eq 'move') { + if($env{'form.newfilename'}) { if (!defined($dir)) { $fn=~m:^(.*)/:; - $dir=$1; + $dir=$1; } - if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { + if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) { return; } - # Prepend the directory to the new name to form the basis of the - # url of the new resource. - # - #renaming a dir - #remove last element for current dir - if ($fn =~ m|/$|) { $dir =~ s|/[^/]*$||; } - $dest = $dir."/".$ENV{'form.newfilename'}; + $dest = $dir."/"; + $dest_newname = $env{'form.newfilename'}; + $env{'form.newfilename'} =~ /.+(\/.+$)/; + $disp_newname = $1; + $disp_newname =~ s/\///; } - } elsif ($ENV{'form.action'} eq 'delete') { - if(!&Delete2($r, $uname, $ENV{'form.newfilename'})) { + } elsif ($env{'form.action'} eq 'delete') { + if(!&Delete2($r, $uname, $env{'form.newfilename'})) { return ; } # Once a resource is deleted, we just list the directory that # previously held it. # $dest = $dir."/."; # Parent dir. - } elsif ($ENV{'form.action'} eq 'copy') { - if($ENV{'form.newfilename'}) { - if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { - return - } - $dest = $ENV{'form.newfilename'}; - - } else { - $r->print('No New filename specified
'); + } elsif ($env{'form.action'} eq 'copy') { + if($env{'form.newfilename'}) { + if(!&Copy2($r, $uname, $dir, $fn, $env{'form.newfilename'})) { + return ; + } + $dest = $env{'form.newfilename'}; + } else { + $r->print(''.&mt('No New filename specified').'
'); return; } - } elsif ($ENV{'form.action'} eq 'newdir') { - # - # Since the newfilename form field is construction space - # relative, ew need to prepend the current path; now in $fn. - # - my $newdir= $fn.$ENV{'form.newfilename'}; + } elsif ($env{'form.action'} eq 'newdir') { + my $newdir= $env{'form.newfilename'}; if(!&NewDir2($r, $uname, $newdir)) { return; } - $dest = $newdir."/" + $dest = $newdir."/"; + } + if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { + $r->print('Unknown Action
'); - return OK; - } - if ($ENV{'form.phase'} eq 'two') { - &Debug($r, "loncfile::handler entering phase2"); - &phasetwo($r,$fn,$uname,$udom); - } else { - &Debug($r, "loncfile::handler entering phase1"); - &phaseone($r,$fn,$uname,$udom); - } + if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { + $r->print(''.&mt('Unknown Action').' '.$env{'form.action'}.'
'. + &Apache::loncommon::end_page()); + return OK; + } + if ($env{'form.phase'} eq 'two') { + &Debug($r, "loncfile::handler entering phase2"); + &phasetwo($r,$fn,$uname,$udom); + } else { + &Debug($r, "loncfile::handler entering phase1"); + &phaseone($r,$fn,$uname,$udom); + } - $r->print('