'.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.');
@@ -974,11 +1028,11 @@ sub build_access_summary {
$showstart = &mt('Deleted');
$showend = $showstart;
} else {
- $showstart = localtime($start);
+ $showstart = &Apache::lonlocal::locallocaltime($start);
if ($end == 0) {
$showend = &mt('No end date');
} else {
- $showend = localtime($end);
+ $showend = &Apache::lonlocal::locallocaltime($end);
}
}
$r->print(''.&mt($scope_desc{$scope}));
@@ -1076,8 +1130,8 @@ sub update_access {
}
}
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $r->print(''.&mt('Allowing others to retrieve file: [_1]',
- $port_path.$file_name).''."\n");
+ $r->print(''.&mt('Allowing others to retrieve file: [_1]',
+ ''.$port_path.$file_name.'').''."\n");
$file_name = &prepend_group($file_name);
my ($uname,$udom) = &get_name_dom($group);
my ($errors,$outcome,$deloutcome,$new_values,$translation);
@@ -1177,9 +1231,11 @@ sub update_access {
'currentpath' => $env{'form.currentpath'},
'access' => $env{'form.selectfile'}
);
- $r->print(' '.&make_anchor($url, \%anchor_fields, &mt('Display all access settings for this file')));
+ my @actions;
+ push(@actions, &make_anchor($url, \%anchor_fields, &mt('Display all access settings for this file')));
delete $anchor_fields{'access'};
- $r->print(' '.&make_anchor($url,\%anchor_fields,&mt('Return to directory')));
+ push(@actions, &make_anchor($url,\%anchor_fields,&mt('Return to directory')));
+ $r->print(' '.&Apache::lonhtmlcommon::actionbox(\@actions));
}
return;
}
@@ -1942,10 +1998,14 @@ sub upload {
my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formname.'.filename'});
my ($state,$msg);
if ($fname eq '') {
- my $msg = &mt('Invalid filename: [_1]; the name of the uploaded file did not contain any letters, '.
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Invalid filename: [_1]; the name of the uploaded file did not contain any letters, '.
'so after eliminating special characters there was nothing left.',
- ''.$env{'form.uploaddoc.filename'}.'');
- $r->print($msg.&done('Back',$url));
+ ''.$env{'form.uploaddoc.filename'}.''),1)));
+
+ $r->print(&done(undef,$url));
return;
}
my $disk_quota = &get_quota($group);
@@ -1962,7 +2022,7 @@ sub upload {
if ($state eq 'will_exceed_quota'
|| $state eq 'file_locked'
|| $state eq 'zero_bytes') {
- $r->print($msg.&done('Back',$url));
+ $r->print($msg.&done(undef,$url));
return;
}
@@ -2058,14 +2118,20 @@ $group_elem
END
} else {
- $r->print(''.&mt('An error occurred ([_1]) while trying to upload [_2].'
- ,$result,&display_file(undef,$fname)).' ');
- $r->print(&done('Back',$url));
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('An error occurred ([_1]) while trying to upload [_2].'
+ ,$result,&display_file(undef,$fname)),1)));
+ $r->print(&done(undef,$url));
}
} elsif ($result !~ m|^/uploaded/|) {
- $r->print(''.&mt('An error occurred ([_1]) while trying to upload [_2].'
- ,$result,&display_file(undef,$fname)).' ');
- $r->print(&done('Back',$url));
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('An error occurred ([_1]) while trying to upload [_2].'
+ ,$result,&display_file(undef,$fname)),1)));
+ $r->print(&done(undef,$url));
} else {
if (!&suppress_embed_prompt()) {
if ($mimetype eq 'text/html') {
@@ -2073,11 +2139,14 @@ END
&print_dependency_form($r,$url,\%allfiles,\%codebase,$result);
return;
} else {
- $r->print(''.&mt('Completed upload of the file.').' '.
- &mt('No embedded items identified.').' ');
+ $r->print(''.&mt('No embedded items identified.').' ');
}
}
}
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('File successfully uploaded'))));
$r->print(&done(undef,$url));
}
return;
@@ -2090,6 +2159,7 @@ sub hidden_elems {
}
return <
+
@@ -2111,7 +2181,10 @@ sub print_dependency_form {
$r->print(''.&mt("Reference Information").'');
}
if ($num) {
- $r->print(''.&mt("Completed upload of the file. This file contained references to other files. You must upload the referenced files or else the uploaded file may not work properly.").' '.
+ $r->print(''.&mt('Completed upload of the file.').' '.
+ &mt('This file contained references to other files.').' '.
+ &mt('You must upload the referenced files or else the uploaded file may not work properly.').
+ ' '.
''.&mt("Please select the locations from which the referenced files are to be uploaded.").' '.
$embedded.
''.&mt('or').' '.&done('Return to directory',$url));
@@ -2143,7 +2216,7 @@ sub overwrite {
my $msg = &mt('Invalid filename: [_1]; the name of the uploaded file did not contain any letters, '.
'so after eliminating special characters there was nothing left.',
''.$env{'form.filename'}.'');
- $r->print($msg.&done('Back',$url));
+ $r->print($msg.&done(undef,$url));
return;
}
$env{'form.'.$formname.'.filename'} = $fname;
@@ -2154,8 +2227,8 @@ sub overwrite {
\%allfiles,\%codebase,undef,undef,undef,
undef,undef,undef,\$mimetype);
if ($result !~ m|^/uploaded/|) {
- $r->print(''.&mt('An error occurred ([_1]) while trying to overwrite [_2].'
- ,$result,&display_file(undef,$fname)).' ');
+ $r->print(''.&mt('An error occurred ([_1]) while trying to overwrite [_2].'
+ ,$result,&display_file(undef,$fname)).' ');
$r->print(&after_overwrite(&mt('Back'),$url));
} else {
if ($mode eq 'parse') {
@@ -2213,7 +2286,7 @@ sub lock_info {
$filetext = ''.$env{'form.lockinfo'}.
' (group: '.$group.')';
} else {
- $filetext = ''.$file_name.'';
+ $filetext = ''.$file_name.'';
}
my $title =''.&Apache::lonnet::gettitle($$array_item[0]).
@@ -2236,20 +2309,36 @@ sub lock_info {
}
}
}
- $r->print(&done(&mt('Back'),$url));
+ $r->print(&done(undef,$url));
return 'ok';
}
sub createdir {
my ($r,$url,$group)=@_;
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
+ # Display warning in case of directory name cleaning has changed the directory name
+ if ($newdir ne $env{'form.newdir'}) {
+ $r->print(
+ ''
+ .&mt('Invalid characters')
+ .' '
+ .&mt('The new directory name was changed from [_1] to [_2].'
+ ,''.$env{'form.newdir'}.''
+ ,''.$newdir.'')
+ .' '
+ );
+ }
+
+ # Directory name empty?
if ($newdir eq '') {
- $r->print(''.
- &mt("Error: no directory name was provided.").
- ' ');
- $r->print(&done(undef,$url));
- return;
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Error: no directory name was provided.'),1)));
+ $r->print(&done(undef,$url));
+ return;
}
+
my $portfolio_root = &get_portfolio_root();
my ($dirlistref,$listerror) = &get_dir_list($portfolio_root,undef,$group);
my $found_file = 0;
@@ -2261,26 +2350,32 @@ sub createdir {
}
}
}
- if ($found_file){
- $r->print(''
- .&mt('Unable to create a directory named [_1].',''.$newdir.'')
- .' '.&mt('A file or directory by that name already exists.').' ');
+ if ($found_file) {
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Unable to create a directory named [_1].'
+ ,''.$newdir.''),1)
+ .' '.&mt('A file or directory by that name already exists.')));
} else {
my ($uname,$udom) = &get_name_dom($group);
my $port_path = &get_port_path();
my $result=&Apache::lonnet::mkdiruserfile($uname,$udom,
$port_path.$env{'form.currentpath'}.$newdir);
if ($result ne 'ok') {
- $r->print(''
- .&mt('An error occurred ([_1]) while trying to create a new directory [_2].'
- ,$result,&display_file())
- .' ');
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('An error occurred ([_1]) while trying to create a new directory [_2].'
+ ,$result,&display_file()),1)));
+
+ } else {
+ $r->print(
+ &Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(
+ &mt('Directory successfully created'))));
}
}
- if ($newdir ne $env{'form.newdir'}) {
- $r->print(&mt('The new directory name was changed from [_1] to [_2].'
- ,''.$env{'form.newdir'}.'',''.$newdir.''));
- }
$r->print(&done(undef,$url));
}
@@ -2368,12 +2463,13 @@ sub get_port_path {
sub missing_priv {
my ($r,$url,$priv) = @_;
- my $longtext = {
+ my %longtext =
+ &Apache::lonlocal::texthash(
upload => 'upload files',
delete => 'delete files',
rename => 'rename files',
setacl => 'set access controls for files',
- };
+ );
my $escpath = &HTML::Entities::encode($env{'form.currentpath'},'&<>"');
my $rtnlink = 'print(' '.&mt("in the group's group portfolio."));
$rtnlink .= &group_args()
} else {
- $r->print(&mt('in this portfolio.'));
+ $r->print(' '.&mt('in this portfolio.'));
}
$rtnlink .= '">'.&mt('Return to directory').'';
$r->print(' '.$rtnlink);
@@ -2451,6 +2547,7 @@ sub embedded_form_elems {
my ($container) = @_;
my $state = <
+
@@ -2467,7 +2564,7 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['selectfile','currentpath','meta','lockinfo','currentfile','action',
'fieldname','mode','rename','continue','group','access','setnum',
- 'cnum','cdom','type','setroles','showversions','ref']);
+ 'cnum','cdom','type','setroles','showversions','ref','symb']);
my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc);
if ($r->uri =~ m|^(/adm/)([^/]+)|) {
$url = $1.$2;
@@ -2570,18 +2667,52 @@ sub handler {
}
}
$r->rflush();
+ # Check if access to portfolio is blocked by one or more blocking events in courses.
my ($blocked,$blocktext) =
&Apache::loncommon::blocking_status('port',$uname,$udom);
if ($blocked) {
- $r->print($blocktext);
- $r->print(&Apache::loncommon::end_page());
- return OK;
+ my $evade_block;
+ # If portfolio display is in a window popped up from a "Select Portfolio Files"
+ # link in a .task resource, check if access to the task included proctor validation
+ # of check-in to a slot limited by IP.
+ # If so, and the slot is between its open and close dates, override the block.
+ if ($env{'request.course.id'} && $env{'form.symb'}) {
+ (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
+ if ($res =~ /\.task$/i) {
+ my %history =
+ &Apache::lonnet::restore($env{'form.symb'},$env{'request.course.id'},
+ $env{'user.domain'},$env{'user.name'});
+ my $version = $history{'resource.0.version'};
+ if ($history{'resource.'.$version.'.0.checkedin'}) {
+ if ($history{'resource.'.$version.'.0.checkedin.slot'}) {
+ my %slot = &Apache::lonnet::get_slot($history{'resource.'.$version.'.0.checkedin.slot'});
+ if ($slot{'ip'}) {
+ if (&Apache::loncommon::check_ip_acc($slot{'ip'})) {
+ my $now = time;
+ if (($slot{'slottime'} < $now) && ($slot{'endtime'} > $now)) {
+ $evade_block = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ unless ($evade_block) {
+ $r->print($blocktext);
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
}
if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
- $r->print('');
- $r->print(&mt('No file was selected to upload.').' ');
- $r->print(&mt('To upload a file, click Browse... and select a file, then click Upload.'));
- $r->print('');
+ $r->print(
+ ''
+ .&mt('No file was selected to upload.')
+ .'< '
+ .&mt('To upload a file, click [_1]Browse...[_2] and select a file, then click [_1]Upload[_2].'
+ ,'','')
+ .' '
+ );
}
if ($env{'form.meta'}) {
&open_form($r,$url);
@@ -2619,8 +2750,8 @@ sub handler {
} elsif ($env{'form.action'} eq 'modify_orightml') {
if ($can_upload) {
my $result =
- &Apache::loncommon::modify_html_refs('portfolio',$port_path,$uname,$udom,$group,
- $portfolio_root,$group);
+ &Apache::loncommon::modify_html_refs('portfolio',$port_path,$uname,
+ $udom,$portfolio_root);
$r->print($result.
&done('Return to directory',$url));
} else {
|