'.
'Actions | | Name | Size | Last Modified | Current Access Status |
');
}
- $r->print("\n".&group_form_data()."\n");
-
+ if (defined($group)) {
+ $r->print("\n".$groupitem."\n");
+ }
my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;
my $href_edit_location="/editupload/$udom/$uname/$port_path".$current_path;
my @dir_lines;
+ my @version_lines;
my %versioned;
foreach my $line (sort
{
@@ -210,14 +234,30 @@ sub display_directory {
$filename =~ s/\s+$//;
my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
if ($version) {
- $versioned{$fname} .= $version.",";
+ push(@version_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
+ $versioned{$fname.'.'.$extension} .= $version.",";
+ } else {
+ push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
}
- push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
}
foreach my $line (@dir_lines) {
my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$line;
my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) {
+ my %version_flag;
+ my $show_versions;
+ if ($env{'form.showversions'} eq $filename) {
+ $show_versions = 'true';
+ }
+ if (exists($versioned{$filename})) {
+ if ($show_versions) {
+ $version_flag{$filename} = '';
+ } else {
+ $version_flag{$filename} = '';
+ }
+ } else {
+ $version_flag{$filename} = '';
+ }
if ($dirptr&$testdir) {
my $colspan='colspan="2"';
if ($select_mode eq 'true'){
@@ -225,19 +265,13 @@ sub display_directory {
}
$r->print(' | ');
$r->print('Go to ... | ');
- $r->print(''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).' | ');
+ $r->print(''.$version_flag{$filename}.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group,$refarg).'/ | ');
$r->print('
');
} else {
my $css_class = 'LC_browser_file';
my $line;
- my $version_flag;
- if (exists($versioned{$fname})) {
- $version_flag = "*";
- } else {
- $version_flag = "";
- }
- my $fullpath = $current_path.$filename;
- $fullpath = &prepend_group($fullpath);
+ my $fullpath = $current_path.$filename;
+ $fullpath = &prepend_group($fullpath,$group);
if ($select_mode eq 'true') {
$line=' | ';
} else {
if (exists $locked_files{$fullpath}) {
- $line.='Locked | ';
+ $line.='Locked | ';
$css_class= 'LC_browser_file_locked';
} else {
if (!$can_modify) {
@@ -260,14 +294,12 @@ sub display_directory {
if ($can_modify) {
my $cat='';
- $line .= 'Rename';
- $line .= ''.$cat.'';
+ $line .= 'Rename';
+ $line .= ' | '.$version_flag{$filename}.''.$cat.'';
}
$line .= ' | ';
}
}
- $r->print('');
- $r->print($line);
my $curr_access;
if ($select_mode ne 'true') {
my $pub_access = 0;
@@ -301,19 +333,28 @@ sub display_directory {
$curr_access = join('+ ',@allaccesses);
}
}
- $r->print(' | ');
- $r->print(''.
- $filename.' | ');
- $r->print(''.$size.' | ');
- $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | ');
- if ($select_mode ne 'true') {
- $r->print(''.
- &mt($curr_access).' ');
- $r->print(''.$access_admin_text.' | ');
+ &display_directory_line($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class, $line, \%access_controls, $curr_access,
+ $now, \%version_flag, $href_location, $url, $current_path, $groupecho, $access_admin_text);
+# $r->print('
');
+# $r->print($line);
+# $r->print(' | ');
+# $r->print(''.$version_flag{$filename}.''.
+# $filename.' | ');
+# $r->print(''.$size.' | ');
+# $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | ');
+# if ($select_mode ne 'true') {
+# $r->print(''.
+# &mt($curr_access).' ');
+# $r->print(''.$access_admin_text.' | ');
+# }
+# $r->print('
'.$/);
+ if ($show_versions) {
+ &display_directory_line($r,$select_mode,$fullpath, $css_class, $line, \%access_controls,
+ $now, \%version_flag, $href_location, $url, $current_path, $groupecho, $access_admin_text);
+
}
- $r->print(''.$/);
}
}
}
@@ -355,7 +396,7 @@ sub open_form {
}
sub close_form {
- my ($r,$url,$button_text)=@_;
+ my ($r,$url,$group,$button_text)=@_;
if (!defined($button_text)) {
$button_text = {
'continue' => &mt('Continue'),
@@ -363,12 +404,27 @@ sub close_form {
};
}
$r->print('');
- $r->print(&group_form_data().'
');
+ if (defined($group)) {
+ $r->print("\n".'');
+ if (exists($env{'form.ref'})) {
+ $r->print("\n".'');
+ }
+ }
+ $r->print('');
$r->print('');
}
@@ -395,47 +451,52 @@ sub display_file {
}
sub done {
- my ($message,$url)=@_;
+ my ($message,$url,$group,$refarg)=@_;
unless (defined $message) {
$message='Done';
}
my $result = '';
return $result;
}
sub delete {
- my ($r,$url)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my @check;
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $file_name = &prepend_group($file_name);
+ $file_name = &prepend_group($file_name,$group);
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
- my ($uname,$udom) = &get_name_dom();
+ 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));
+ $r->print(&done('Back',$url,$group,$refarg));
} else {
if (scalar(@files)) {
&open_form($r,$url);
$r->print(''.&mt('Delete').' '.&display_file(undef,\@files).'?
');
- &close_form($r,$url);
+ &close_form($r,$url,$group);
} else {
$r->print("No file was checked to delete.
");
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group,$refarg));
}
}
}
sub delete_confirmed {
- my ($r,$url)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
my $result;
- my ($uname,$udom) = &get_name_dom();
- my $port_path = &get_port_path();
+ my ($uname,$udom) = &get_name_dom($group);
+ my $port_path = &get_port_path($group);
foreach my $delete_file (@files) {
$result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$env{'form.currentpath'}.
@@ -445,23 +506,23 @@ sub delete_confirmed {
') while trying to delete '.&display_file(undef, $delete_file).'
');
}
}
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub delete_dir {
- my ($r,$url)=@_;
+ my ($r,$url,$group)=@_;
&open_form($r,$url);
$r->print(''.&mt('Delete').' '.&display_file().'?
');
- &close_form($r,$url);
+ &close_form($r,$url,$group);
}
sub delete_dir_confirmed {
- my ($r,$url)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $directory_name = $env{'form.currentpath'};
$directory_name =~ s|/$||; # remove any trailing slash
- my ($uname,$udom) = &get_name_dom();
- my $namespace = &get_namespace();
- my $port_path = &get_port_path();
+ my ($uname,$udom) = &get_name_dom($group);
+ my $namespace = &get_namespace($group);
+ my $port_path = &get_port_path($group);
my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$directory_name);
@@ -481,35 +542,35 @@ sub delete_dir_confirmed {
}
$env{'form.currentpath'} = $directory_name;
}
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub rename {
- my ($r,$url)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
- my ($uname,$udom) = &get_name_dom();
- $file_name = &prepend_group($file_name);
+ 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));
+ $r->print(&done(undef,$url,$group,$refarg));
} else {
&open_form($r,$url);
$r->print(''.&mt('Rename').' '.&display_file().' to
?
');
- &close_form($r,$url);
+ &close_form($r,$url,$group);
}
}
sub rename_confirmed {
- my ($r,$url)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
- my ($uname,$udom) = &get_name_dom();
- my $port_path = &get_port_path();
+ my ($uname,$udom) = &get_name_dom($group);
+ my $port_path = &get_port_path($group);
if ($filenewname eq '') {
$r->print(''.
&mt("Error: no valid filename was provided to rename to.").
'
');
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group,$refarg));
return;
}
my $result=
@@ -527,35 +588,20 @@ sub rename_confirmed {
''.&display_file('',$env{'form.filenewname'}).'',
''.&display_file('',$filenewname).''));
}
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group,$refarg));
}
sub display_access {
- my ($r,$url,$group,$can_setacl,$port_path) = @_;
- my ($uname,$udom) = &get_name_dom();
+ 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);
+ $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.').
- '
';
+ 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);
@@ -564,18 +610,19 @@ sub display_access {
'continue' => &mt('Proceed'),
'cancel' => &mt('Back to directory listing'),
};
- &close_form($r,$url,$button_text);
+ &close_form($r,$url,$group,$button_text);
} else {
$r->print($header);
if ($aclcount) {
$r->print($info);
}
- &view_access_settings($r,$url,$access_controls{$file_name},$aclcount);
+ &view_access_settings($r,$url,$group,$access_controls{$file_name},
+ $aclcount,$refarg);
}
}
sub view_access_settings {
- my ($r,$url,$access_controls,$aclcount) = @_;
+ my ($r,$url,$group,$access_controls,$aclcount,$refarg) = @_;
my ($showstart,$showend);
my %todisplay;
foreach my $key (sort(keys(%{$access_controls}))) {
@@ -596,8 +643,15 @@ sub view_access_settings {
} else {
$r->print(&mt('No access control settings currently exist for this file.
' ));
}
+ my $group_arg;
+ if ($group) {
+ $group_arg = '&group='.$group;
+ if ($refarg ne '') {
+ $group_arg .= '&'.$refarg;
+ }
+ }
$r->print('
'.&mt('Return to directory listing').'');
+ $group_arg.'">'.&mt('Return to directory listing').'');
return;
}
@@ -705,7 +759,7 @@ sub build_access_summary {
sub update_access {
- my ($r,$url,$group,$port_path) = @_;
+ my ($r,$url,$group,$port_path,$refarg) = @_;
my $totalprocessed = 0;
my %processing;
my %title = (
@@ -732,8 +786,8 @@ sub update_access {
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
$r->print(''.&mt('Allowing others to retrieve portfolio file: [_1]',
$port_path.$file_name).'
'."\n");
- $file_name = &prepend_group($file_name);
- my ($uname,$udom) = &get_name_dom();
+ $file_name = &prepend_group($file_name,$group);
+ my ($uname,$udom) = &get_name_dom($group);
my ($errors,$outcome,$deloutcome,$new_values,$translation);
if ($totalprocessed) {
($outcome,$deloutcome,$new_values,$translation) =
@@ -804,7 +858,7 @@ sub update_access {
if ($allnew > 0) {
my $now = time;
my $then = $now + (60*60*24*180); # six months approx.
- &open_form($r,$url);
+ &open_form($r,$url,$group);
foreach my $newitem ('course','group','domains','users') {
if ($env{'form.new'.$newitem} > 0) {
$r->print('
'.&mt('Add new [_1]-based access control for portfolio file: [_2]',$newitem,$env{'form.currentpath'}.$env{'form.selectfile'}).'
');
@@ -819,14 +873,21 @@ sub update_access {
$access_controls{$file_name},$now,$then);
}
}
- &close_form($r,$url);
+ &close_form($r,$url,$group);
} else {
+ my $group_arg;
+ if ($group) {
+ $group_arg = '&group='.$group;
+ if ($refarg) {
+ $group_arg .= '&'.$refarg;
+ }
+ }
$r->print('
'.
+ '¤tpath='.$env{'form.currentpath'}.$group_arg.'">'.
&mt('Display all access settings for this file').''.
' '.
''.&mt('Return to directory listing').'');
+ $group_arg.'">'.&mt('Return to directory listing').'');
}
return;
}
@@ -996,25 +1057,24 @@ sub access_setting_table {
$passwd.'" />');
$r->print(&Apache::loncommon::end_data_table_row());
$r->print(&Apache::loncommon::end_data_table());
-
- #$r->print(' |
');
- #&access_element($r,'domains',\%acl_count,\@domains,$access_controls,$now,$then);
- #$r->print(' | | ');
- #&access_element($r,'users',\%acl_count,\@users,$access_controls,$now,$then);
- #$r->print(' |
|
');
- #if (@courses > 0 || @groups > 0) {
- # $r->print('');
- #} else {
- # $r->print(' | ');
- #}
- #&access_element($r,'course',\%acl_count,\@courses,$access_controls,$now,$then);
- #$r->print(' | ');
- #if (@courses > 0 || @groups > 0) {
- # $r->print('
|
');
- #} else {
- # $r->print(' | | ');
- #}
- #&access_element($r,'group',\%acl_count,\@groups,$access_controls,$now,$then);
+ $r->print(' |
|
');
+ &access_element($r,'domains',\%acl_count,\@domains,$access_controls,$now,$then);
+ $r->print(' | | ');
+ &access_element($r,'users',\%acl_count,\@users,$access_controls,$now,$then);
+ $r->print(' |
|
');
+ if (@courses > 0 || @groups > 0) {
+ $r->print('');
+ } else {
+ $r->print(' | ');
+ }
+ &access_element($r,'course',\%acl_count,\@courses,$access_controls,$now,$then);
+ $r->print(' | ');
+ if (@courses > 0 || @groups > 0) {
+ $r->print('
|
');
+ } else {
+ $r->print(' | | ');
+ }
+ &access_element($r,'group',\%acl_count,\@groups,$access_controls,$now,$then);
$r->print(' |
');
}
@@ -1395,7 +1455,7 @@ END_SCRIPT
}
sub select_files {
- my ($r) = @_;
+ my ($r,$group) = @_;
if ($env{'form.continue'} eq 'true') {
# here we update the selections for the currentpath
# eventually, have to handle removing those not checked, but . . .
@@ -1439,9 +1499,8 @@ ENDSMP
}
}
}
-
sub upload {
- my ($r,$url,$group)=@_;
+ my ($r,$url,$group,$refarg)=@_;
my $fname=$env{'form.uploaddoc.filename'};
my $filesize = (length($env{'form.uploaddoc'})) / 1000; #express in k (1024?)
my $disk_quota = 20000; # expressed in k
@@ -1455,20 +1514,19 @@ sub upload {
}
$fname=&Apache::lonnet::clean_filename($fname);
- my $portfolio_root=&get_portfolio_root();
- my ($uname,$udom) = &get_name_dom();
- my $port_path = &get_port_path();
+ my $portfolio_root=&get_portfolio_root($group);
+ my ($uname,$udom) = &get_name_dom($group);
+ my $port_path = &get_port_path($group);
# Fixme --- Move the checking for existing file to LOND error return
- my @dir_list=&get_dir_list($portfolio_root);
+ my @dir_list=&get_dir_list($portfolio_root,$group);
my $found_file = 0;
my $locked_file = 0;
foreach my $line (@dir_list) {
my ($file_name)=split(/\&/,$line,2);
if ($file_name eq $fname){
$file_name = $env{'form.currentpath'}.$file_name;
- $file_name = &prepend_group($file_name);
+ $file_name = &prepend_group($file_name,$group);
$found_file = 1;
- # FIXME I think this is incorrect, prepend_group took care of this?
if (defined($group)) {
$file_name = $group.'/'.$file_name;
}
@@ -1481,17 +1539,17 @@ sub upload {
if (($current_disk_usage + $filesize) > $disk_quota){
$r->print('