--- loncom/publisher/loncfile.pm 2012/06/04 19:23:41 1.115 +++ loncom/publisher/loncfile.pm 2013/07/03 05:03:19 1.120 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.115 2012/06/04 19:23:41 raeburn Exp $ +# $Id: loncfile.pm,v 1.120 2013/07/03 05:03:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,7 @@ =head1 NAME -Apache::loncfile - Construction space file management. +Apache::loncfile - Authoring space file management. =head1 SYNOPSIS @@ -68,7 +68,6 @@ use File::Basename; use File::Copy; use HTML::Entities(); use Apache::Constants qw(:common :http :methods); -use Apache::loncacc; use Apache::lonnet; use Apache::loncommon(); use Apache::lonlocal; @@ -102,7 +101,7 @@ my $r; # Needs to be global for some =cut sub Debug { - # Put out the indicated message butonly if DEBUG is true. + # Put out the indicated message but only if DEBUG is true. if ($DEBUG) { my ($r,$message) = @_; $r->log_reason($message); @@ -110,14 +109,15 @@ sub Debug { } sub done { - my ($url)=@_; - my $done=&mt("Done"); - return(<$done - -ENDDONE + my ($url) = @_; + return + '

' + .&Apache::lonhtmlcommon::confirm_success(&mt("Done")) + .'
'.&mt("Continue").'' + .'' + .'

'; } =pod @@ -235,7 +235,7 @@ sub empty_directory { =item exists($user, $domain, $file) - Determine if a resource file name has been published or exists + Determine if a resource filename has been published or exists in the construction space. Parameters: @@ -368,7 +368,7 @@ sub cleanDest { ($newpath,$error)=&relativeDest($fn,$newpath,$uname,$udom); if (! -d "$newpath") { $request->print('

' - .&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." + .&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|.*/||; @@ -409,7 +409,7 @@ sub relativeDest { while ($newfilename=~m{/\.\./}) { $newfilename=~ s{/[^/]+/\.\./}{/}g; #remove dir/.. } - my ($authorname,$authordom)=&Apache::loncacc::constructaccess($newfilename); + my ($authorname,$authordom)=&Apache::lonnet::constructaccess($newfilename); unless (($authorname) && ($authordom)) { my $otherdir = &display($newfilename); $error = &mt('Access denied to [_1]',$otherdir); @@ -437,9 +437,9 @@ Parameters: sub CloseForm1 { my ($request, $fn) = @_; - $request->print('

'); - $request->print('

'); + $request->print(''); + $request->print('
'. + '
'); } @@ -700,9 +700,21 @@ sub Copy1 { my ($type,$return)=&exists($user, $domain, $newfilename); $request->print($return); if ($type eq 'error') { - $request->print('
'.&mt('Cancel').''); + $request->print('
'.&mt('Cancel').''); return; } +# Check if there is enough space. + my @fileinfo = stat($fn); + my ($dir,$fname) = ($fn =~ m{^(.+/)([^/]+)$}); + my $filesize = $fileinfo[7]; + $filesize = int($filesize/1000); #expressed in kb + my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$domain/$user"; + my $output = &Apache::loncommon::excess_filesize_authorspace($user,$domain,$authorspace, + $fname,$filesize,'copy'); + if ($output) { + $request->print($output.'
'.&mt('Cancel').''); + return; + } $request->print( '' @@ -825,7 +837,7 @@ Parameters: =item $domain - Name of the domain of the user -=item $fn - Source file name +=item $fn - Source filename =item $newfilename - Name of the file to be created; no path information @@ -838,7 +850,7 @@ 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 Cancel -button which returns you to the driectory listing you came from +button which returns you to the directory listing you came from =back @@ -880,7 +892,7 @@ sub NewFile1 { '
'. ''. ''. - ''.&mt('Enter a file name: ').' '. + ''.&mt('Enter a filename: ').' '. '

'. '

'); @@ -962,8 +974,8 @@ sub phaseone { $dirlist=$fn; } $r->print('
'.$error.'
'. - '

'.&mt('Return to Directory'). - '

'); + '

'.&mt('Return to Directory'). + '

'); return; } $r->print('
'. @@ -1099,7 +1111,7 @@ sub Rename2 { } } else { $request->print( - '

' + '

' .&mt('No such file: [_1]', &display($oldfile)) .'

' @@ -1387,11 +1399,19 @@ sub phasetwo { $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('

'.&mt('Done').'

'); + $r->print( + '

' + .&Apache::lonhtmlcommon::confirm_success(&mt('Done')) + .'
'.&mt('Continue').'' + .'

' + ); } else { if ($env{'form.action'} eq 'rename') { - $r->print('

'.&mt('Return to Directory').'

'); - $r->print('

'.$disp_newname.'

'); + $r->print( + '

'.&Apache::lonhtmlcommon::confirm_success(&mt('Done')).'

' + .&Apache::lonhtmlcommon::actionbox( + [''.&mt('Return to Directory').'', + ''.$disp_newname.''])); } else { $r->print(&done(&url($dest))); } @@ -1442,7 +1462,7 @@ sub handler { # ----------------------------------------------------------- Start page output - my ($uname,$udom) = &Apache::loncacc::constructaccess($fn); + my ($uname,$udom) = &Apache::lonnet::constructaccess($fn); &Debug($r, "loncfile::handler constructaccess uname = $uname domain = $udom"); if (($uname eq '') || ($udom eq '')) { @@ -1480,16 +1500,16 @@ function writeDone() { # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', + 'text' => 'Authoring Space', 'href' => &Apache::loncommon::authorspace($fn), }); &Apache::lonhtmlcommon::add_breadcrumb({ 'text' => 'File Operation', - 'title' => 'Construction Space File Operation', + 'title' => 'Authoring Space File Operation', 'href' => '', }); - $r->print(&Apache::loncommon::start_page('Construction Space File Operation', + $r->print(&Apache::loncommon::start_page('Authoring Space File Operation', $js, {'add_entries' => \%loaditem,}) .&Apache::lonhtmlcommon::breadcrumbs() @@ -1497,7 +1517,7 @@ function writeDone() { &Apache::loncommon::CSTR_pageheader($trailfile)) ); - $r->print('

'.&mt('Location').': '.&display($fn).'

'); + $r->print('

'.&mt('Location').': '.&display($fn).'

'); if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { $r->print('

' @@ -1508,37 +1528,35 @@ function writeDone() { &Debug($r, "loncfile::handler Form action is $env{'form.action'} "); - if ($env{'form.action'} eq 'delete') { - $r->print('

'.&mt('Delete').'

'); - } elsif ($env{'form.action'} eq 'rename') { - $r->print('

'.&mt('Rename').'

'); - } elsif ($env{'form.action'} eq 'move') { - $r->print('

'.&mt('Move').'

'); - } elsif ($env{'form.action'} eq 'newdir') { - $r->print('

'.&mt('New Directory').'

'); - } elsif ($env{'form.action'} eq 'decompress') { - $r->print('

'.&mt('Decompress').'

'); - } elsif ($env{'form.action'} eq 'copy') { - $r->print('

'.&mt('Copy').'

'); - } 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' ) { - $r->print('

'.&mt('New Resource').'

'); + my %action = &Apache::lonlocal::texthash( + 'delete' => 'Delete', + 'rename' => 'Rename', + 'move' => 'Move', + 'newdir' => 'New Directory', + 'decompress' => 'Decompress', + 'copy' => 'Copy', + 'newfile' => 'New Resource', + 'newhtmlfile' => 'New Resource', + 'newproblemfile' => 'New Resource', + 'newpagefile' => 'New Resource', + 'newsequencefile' => 'New Resource', + 'newrightsfile' => 'New Resource', + 'newstyfile' => 'New Resource', + 'newtaskfile' => 'New Resource', + 'newlibraryfile' => 'New Resource', + 'Select Action' => 'New Resource', + ); + if ($action{$env{'form.action'}}) { + $r->print('

'.$action{$env{'form.action'}}.'

'); } else { $r->print('

' - .&mt('Unknown Action').' '.$env{'form.action'} + .&mt('Unknown Action: [_1]',$env{'form.action'}) .'

' .&Apache::loncommon::end_page() ); - return OK; + return OK; } + if ($env{'form.phase'} eq 'two') { &Debug($r, "loncfile::handler entering phase2"); &phasetwo($r,$fn,$uname,$udom);