--- loncom/publisher/loncfile.pm 2011/10/23 23:46:07 1.110
+++ loncom/publisher/loncfile.pm 2014/06/14 21:40:05 1.122
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.110 2011/10/23 23:46:07 www Exp $
+# $Id: loncfile.pm,v 1.122 2014/06/14 21:40:05 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(< '
+ .&Apache::lonhtmlcommon::confirm_success(&mt("Done"))
+ .' '.&mt('Error: destination for operation is an existing directory.').' '
- .&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))
.'
'.&mt("Continue").''
+ .''
+ .'
'.&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 $output = &Apache::loncommon::excess_filesize_warning($user,$domain,'author',
+ $fname,$filesize,'copy');
+ if ($output) {
+ $request->print($output.'
'.&mt('Cancel').'');
+ return;
+ }
$request->print(
''
@@ -826,7 +836,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
@@ -839,7 +849,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
@@ -881,7 +891,7 @@ sub NewFile1 {
'
'.&mt('Return to Directory'). + '
'); return; } $r->print('' @@ -1388,11 +1398,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(''
+ .&Apache::lonhtmlcommon::confirm_success(&mt('Done'))
+ .'
'.&mt('Continue').''
+ .'
'.&Apache::lonhtmlcommon::confirm_success(&mt('Done')).'
' + .&Apache::lonhtmlcommon::actionbox( + [''.&mt('Return to Directory').'', + ''.$disp_newname.''])); } else { $r->print(&done(&url($dest))); } @@ -1442,14 +1460,11 @@ sub handler { } # ----------------------------------------------------------- Start page output - my $uname; - my $udom; - ($uname,$udom)= - &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); + my ($uname,$udom) = &Apache::lonnet::constructaccess($fn); &Debug($r, "loncfile::handler constructaccess uname = $uname domain = $udom"); - unless (($uname) && ($udom)) { + if (($uname eq '') || ($udom eq '')) { $r->log_reason($uname.' at '.$udom. ' trying to manipulate file '.$env{'form.filename'}. ' ('.$fn.') - not authorized', @@ -1476,28 +1491,32 @@ function writeDone() { |; $loaditem{'onload'} = "writeDone()"; } + + my $londocroot = $r->dir_config('lonDocRoot'); + my $trailfile = $fn; + $trailfile =~ s{^/(priv/)}{$londocroot/$1}; # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', - 'href' => &Apache::loncommon::authorspace(), + '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() .&Apache::loncommon::head_subbox( - &Apache::loncommon::CSTR_pageheader()) + &Apache::loncommon::CSTR_pageheader($trailfile)) ); - $r->print(''.&mt('Location').': '.&display($fn).'
'); if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { $r->print('' @@ -1508,37 +1527,35 @@ function writeDone() { &Debug($r, "loncfile::handler Form action is $env{'form.action'} "); - if ($env{'form.action'} eq 'delete') { - $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);