--- loncom/publisher/loncfile.pm 2016/05/22 01:09:54 1.124 +++ loncom/publisher/loncfile.pm 2019/03/06 02:31:16 1.125 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.124 2016/05/22 01:09:54 raeburn Exp $ +# $Id: loncfile.pm,v 1.125 2019/03/06 02:31:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -109,13 +109,13 @@ sub Debug { } sub done { - my ($url) = @_; + my ($destfn) = @_; return '
'
.&Apache::lonhtmlcommon::confirm_success(&mt("Done"))
- .'
'.&mt("Continue").''
+ .'
'.&mt("Continue").''
.''
.'
' - .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested filename." - ,&display($newpath)) - .'
'); + $warnings = '' + .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested filename." + ,&display($newpath)) + .'
'; $dest=~s|.*/||; } } - if ($dest =~ /\.(\d+)\.(\w+)$/){ - $request->print(''
- .&mt('Bad filename [_1]',&display($dest))
- .'
'
- .&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
- .'
'
- .&mt('Removing the [_1].number.[_2] from requested filename.','','')
- .'
'
+ .&mt('Bad filename [_1]',&display($dest))
+ .'
'
+ .&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
+ .'
'
+ .&mt('Removing the [_1].number.[_2] from requested filename.','','')
+ .'
' - .&mt('Invalid characters in requested name have been removed.') - .'
' - ); + $warnings .= '' + .&mt('Invalid characters in requested name have been removed.') + .'
'; } - return ($dest,$error); + return ($dest,$error,$warnings); } sub relativeDest { @@ -469,7 +473,7 @@ Parameters: sub CloseForm2 { my ($request, $user, $fn) = @_; - $request->print(&done(&url($fn))); + $request->print(&done($fn)); } =pod @@ -840,6 +844,9 @@ Parameters: =item $newfilename - Name of the file to be created; no path information + +=item $warnings - Information about changes to filename made by cleanDest(). + =back Side Effects: @@ -856,8 +863,8 @@ button which returns you to the director =cut sub NewFile1 { - my ($request, $user, $domain, $fn, $newfilename) = @_; - return if (&filename_check($newfilename) ne 'ok'); + my ($request, $user, $domain, $fn, $newfilename, $warnings) = @_; + return if (&filename_check($newfilename,$warnings) ne 'ok'); if ($env{'form.action'} =~ /new(.+)file/) { my $extension=$1; @@ -870,8 +877,8 @@ sub NewFile1 { } } my ($type, $result)=&exists($user,$domain,$newfilename); - $request->print($result); if ($type eq 'error') { + $request->print($warnings.$result); $request->print(''); } else { my $extension; @@ -883,6 +890,7 @@ sub NewFile1 { my @okexts = qw(xml html xhtml htm xhtm problem page sequence rights sty task library js css txt); if (($extension eq '') || (!grep(/^\Q$extension\E/,@okexts))) { my $validexts = '.'.join(', .',@okexts); + $request->print($warnings.$result); $request->print(''. &mt('Invalid filename: ').&display($newfilename).'
'.
&mt('The name of the new file needs to end with an appropriate file extension to indicate the type of file to create.').'
'.
@@ -895,14 +903,15 @@ sub NewFile1 {
'
'.&mt('Make new file').' '.&display($newfilename).'?
'); $request->print(''); $request->print('' - ); - } - } 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') { + + if ($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 { + if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { + &NewFile1($r, $uname, $udom, $fn, $newfilename, $warnings); + } else { + if ($warnings) { + $r->print($warnings); + } $r->print('' .&mt('No new filename specified.') .'
' ); - } + } + } else { + if ($warnings) { + $r->print($warnings); + } + 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); + } } } @@ -1417,7 +1437,7 @@ sub phasetwo { [''.&mt('Return to Directory').'', ''.$disp_newname.''])); } else { - $r->print(&done(&url($dest))); + $r->print(&done($dest)); } } }