');
}
sub display_file {
my ($path,$filename)=@_;
my $display_file_text;
+ my $file_start='';
+ my $file_end='';
if (!defined($path)) { $path=$env{'form.currentpath'}; }
if (!defined($filename)) {
$filename=$env{'form.selectfile'};
- $display_file_text = ''.$path.$filename.'';
+ $display_file_text = $file_start.$path.$filename.$file_end;
} elsif (ref($filename) eq "ARRAY") {
- foreach (@$filename) {
- $display_file_text .= ''.$path.$_.' ';
+ foreach my $file (@$filename) {
+ $display_file_text .= $file_start.$path.$file.$file_end.' ';
}
} elsif (ref($filename) eq "SCALAR") {
- $display_file_text = ''.$path.$filename.'';
+ $display_file_text = $file_start.$path.$$filename.$file_end;
+ } else {
+ $display_file_text = $file_start.$path.$filename.$file_end;
}
return $display_file_text;
}
sub done {
- my ($message,$url,$group)=@_;
+ my ($message,$url,$group,$refarg)=@_;
unless (defined $message) {
$message='Done';
}
@@ -317,14 +460,17 @@ sub done {
'&fieldname='.$env{'form.fieldname'}.
'&mode='.$env{'form.mode'};
if (defined($group)) {
- $result .= '&group='.$group;
+ $result .= '&group='.$group;
+ if ($refarg ne '') {
+ $result .= '&'.$refarg;
+ }
}
$result .= '">'.&mt($message).'';
return $result;
}
sub delete {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my @check;
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
$file_name = &prepend_group($file_name,$group);
@@ -332,7 +478,7 @@ sub delete {
my ($uname,$udom) = &get_name_dom($group);
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$r->print ("The file is locked and cannot be deleted. ");
- $r->print(&done('Back',$url,$group));
+ $r->print(&done('Back',$url,$group,$refarg));
} else {
if (scalar(@files)) {
&open_form($r,$url);
@@ -340,13 +486,13 @@ sub delete {
&close_form($r,$url,$group);
} else {
$r->print("No file was checked to delete. ");
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url,$group,$refarg));
}
}
}
sub delete_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
my $result;
my ($uname,$udom) = &get_name_dom($group);
@@ -356,11 +502,11 @@ sub delete_confirmed {
$env{'form.currentpath'}.
$delete_file);
if ($result ne 'ok') {
- $r->print(' An error occured ('.$result.
- ') while trying to delete '.&display_file(undef, $delete_file).' ');
+ $r->print(' An error occured ('.$result.
+ ') while trying to delete '.&display_file(undef, $delete_file).' ');
}
}
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub delete_dir {
@@ -371,7 +517,7 @@ sub delete_dir {
}
sub delete_dir_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $directory_name = $env{'form.currentpath'};
$directory_name =~ s|/$||; # remove any trailing slash
my ($uname,$udom) = &get_name_dom($group);
@@ -381,8 +527,8 @@ sub delete_dir_confirmed {
$directory_name);
if ($result ne 'ok') {
- $r->print(' An error occured (dir) ('.$result.
- ') while trying to delete '.$directory_name.' ');
+ $r->print(' An error occured (dir) ('.$result.
+ ') while trying to delete '.$directory_name.' ');
} else {
# now remove from recent
# $r->print(' removing '.$directory_name.' print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub rename {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
my ($uname,$udom) = &get_name_dom($group);
$file_name = &prepend_group($file_name,$group);
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$r->print ("The file is locked and cannot be renamed. ");
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url,$group,$refarg));
} else {
&open_form($r,$url);
$r->print('
'.&mt('Rename').' '.&display_file().' to
@@ -416,15 +562,15 @@ sub rename {
}
sub rename_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
my ($uname,$udom) = &get_name_dom($group);
my $port_path = &get_port_path($group);
if ($filenewname eq '') {
- $r->print(''.
+ $r->print(''.
&mt("Error: no valid filename was provided to rename to.").
- ' ');
- $r->print(&done(undef,$url,$group));
+ ' ');
+ $r->print(&done(undef,$url,$group,$refarg));
return;
}
my $result=
@@ -432,18 +578,884 @@ sub rename_confirmed {
$port_path.$env{'form.currentpath'}.$env{'form.selectfile'},
$port_path.$env{'form.currentpath'}.$filenewname);
if ($result ne 'ok') {
- $r->print(' An errror occured ('.$result.
- ') while trying to rename '.&display_file().' to '.
- &display_file(undef,$filenewname).' ');
+ $r->print(''.
+ &mt('An errror occured ([_1]) while trying to rename [_2]'
+ .' to [_3]',$result,&display_file(),
+ &display_file('',$filenewname)).' ');
}
if ($filenewname ne $env{'form.filenewname'}) {
- $r->print("The new file name was changed from: ".$env{'form.filenewname'}." to $filenewname ");
+ $r->print(&mt("The new file name was changed from: [_1] to [_2]",
+ ''.&display_file('',$env{'form.filenewname'}).'',
+ ''.&display_file('',$filenewname).''));
+ }
+ $r->print(&done(undef,$url,$group,$refarg));
+}
+
+sub display_access {
+ my ($r,$url,$group,$can_setacl,$port_path,$refarg) = @_;
+ my ($uname,$udom) = &get_name_dom($group);
+ my $file_name = $env{'form.currentpath'}.$env{'form.access'};
+ $file_name = &prepend_group($file_name,$group);
+ my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
+ $uname);
+ my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group,$file_name);
+ my $aclcount = keys(%access_controls);
+ my $header = '
'.&mt('Allowing others to retrieve portfolio file: [_1]',$port_path.$env{'form.currentpath'}.$env{'form.access'}).'
';
+ my $info .= &mt('Access to this file by others can be set to be one or more of the following types: public, passphrase-protected or conditional.').'
'.&mt('Public files are available to anyone without the need for login.').'
'.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.').'
'.&mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satisfy the conditions you set.').' '.&mt('The conditions can include affiliation with a particular course or group, or a user account in a specific domain.').' '.&mt('Alternatively access can be granted to people with specific LON-CAPA usernames and domains.').'
';
+ if ($can_setacl) {
+ &open_form($r,$url);
+ $r->print($header.$info);
+ &access_setting_table($r,$access_controls{$file_name});
+ my $button_text = {
+ 'continue' => &mt('Proceed'),
+ 'cancel' => &mt('Back to directory listing'),
+ };
+ &close_form($r,$url,$group,$button_text);
+ } else {
+ $r->print($header);
+ if ($aclcount) {
+ $r->print($info);
+ }
+ &view_access_settings($r,$url,$group,$access_controls{$file_name},
+ $aclcount,$refarg);
+ }
+}
+
+sub view_access_settings {
+ my ($r,$url,$group,$access_controls,$aclcount,$refarg) = @_;
+ my ($showstart,$showend);
+ my %todisplay;
+ foreach my $key (sort(keys(%{$access_controls}))) {
+ my ($num,$scope,$end,$start) = &unpack_acc_key($key);
+ $todisplay{$scope}{$key} = $$access_controls{$key};
+ }
+ if ($aclcount) {
+ $r->print(&mt('