'.
- 'Actions | | Name | Size | Last Modified | Current Access Status |
');
- }
- if (defined($group)) {
- $r->print("\n".$groupitem."\n");
+ 'Actions | | | Name | Size | Last Modified | Current Access Status |
');
}
+ $r->print("\n".&group_form_data()."\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
+ foreach my $dir_line (sort
{
my ($afile)=split('&',$a,2);
my ($bfile)=split('&',$b,2);
@@ -192,18 +250,42 @@ sub display_directory {
} (@$dir_list)) {
#$strip holds directory/file name
#$dom
- my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
+ my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
$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;
+ foreach my $dir_line (@dir_lines) {
+ my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_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})) {
+ %anchor_fields = (
+ 'selectfile' => $filename,
+ 'continue' => 'false',
+ 'currentpath' => $current_path,
+ );
+ if ($show_versions) {
+ $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields,
+ '');
+ } else {
+ $anchor_fields{'showversions'} = $filename;
+ $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields,
+ '');
+ }
+ } else {
+ $version_flag{$filename} = ' ';
+ }
if ($dirptr&$testdir) {
my $colspan='colspan="2"';
if ($select_mode eq 'true'){
@@ -211,19 +293,20 @@ 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'},$group).' | ');
+ %anchor_fields = (
+ 'selectfile' => $filename.'/',
+ 'currentpath' => $current_path.$filename.'/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(''.$version_flag{$filename}.' | '.&make_anchor($url,\%anchor_fields,$filename.'/').' | ');
$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,$group);
+ my $fullpath = $current_path.$filename;
+ $fullpath = &prepend_group($fullpath);
if ($select_mode eq 'true') {
$line=' | ';
} else {
if (exists $locked_files{$fullpath}) {
- $line.='Locked | ';
+ %anchor_fields = (
+ 'lockinfo' => $current_path.$filename
+ );
+ $line.=''.&make_anchor($url,\%anchor_fields,'Locked').' | ';
$css_class= 'LC_browser_file_locked';
} else {
if (!$can_modify) {
@@ -244,16 +330,19 @@ sub display_directory {
$line .= '';
}
if ($can_modify) {
- my $cat='';
- $line .= 'Rename';
- $line .= ''.$cat.'';
+ %anchor_fields = (
+ 'rename' => $filename,
+ currentpath => $current_path
+ );
+ $line .= &make_anchor($url,\%anchor_fields,'Rename');
+ $line .= ' | '.&make_anchor($href_edit_location.$filename.'.meta',undef,$cat);
+ # ''.$cat.'';
}
$line .= ' | ';
}
}
- $r->print('');
- $r->print($line);
my $curr_access;
if ($select_mode ne 'true') {
my $pub_access = 0;
@@ -287,19 +376,21 @@ 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, $access_admin_text);
+ if ($show_versions) {
+ foreach my $dir_line (@version_lines) {
+ my ($v_filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
+ my ($v_fname,$version,$v_extension) = &Apache::grades::file_name_version_ext($v_filename);
+ $line = ' | ';
+ if (($v_fname eq $fname)&&($v_extension eq $extension)) {
+ &display_directory_line($r,$select_mode,$fullpath, $v_filename, $mtime, $size,
+ $css_class, $line, \%access_controls, $curr_access, $now,
+ \%version_flag, $href_location, $url, $current_path, $access_admin_text, 1);
+ }
+ }
}
- $r->print('
'.$/);
}
}
}
@@ -341,7 +432,7 @@ sub open_form {
}
sub close_form {
- my ($r,$url,$group,$button_text)=@_;
+ my ($r,$url,$button_text)=@_;
if (!defined($button_text)) {
$button_text = {
'continue' => &mt('Continue'),
@@ -349,19 +440,12 @@ sub close_form {
};
}
$r->print('');
- if (defined($group)) {
- $r->print("\n".'');
- }
- $r->print('
');
+ $r->print(&group_form_data().'');
$r->print('');
}
@@ -388,49 +472,47 @@ sub display_file {
}
sub done {
- my ($message,$url,$group)=@_;
+ my ($message,$url)=@_;
unless (defined $message) {
$message='Done';
}
my $result = '';
return $result;
}
sub delete {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my @check;
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $file_name = &prepend_group($file_name,$group);
+ $file_name = &prepend_group($file_name);
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
- my ($uname,$udom) = &get_name_dom($group);
+ my ($uname,$udom) = &get_name_dom();
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));
} else {
if (scalar(@files)) {
&open_form($r,$url);
$r->print(''.&mt('Delete').' '.&display_file(undef,\@files).'?
');
- &close_form($r,$url,$group);
+ &close_form($r,$url);
} else {
$r->print("No file was checked to delete.
");
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
}
}
}
sub delete_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
my $result;
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
foreach my $delete_file (@files) {
$result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$env{'form.currentpath'}.
@@ -440,23 +522,23 @@ sub delete_confirmed {
') while trying to delete '.&display_file(undef, $delete_file).'
');
}
}
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
}
sub delete_dir {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
&open_form($r,$url);
$r->print(''.&mt('Delete').' '.&display_file().'?
');
- &close_form($r,$url,$group);
+ &close_form($r,$url);
}
sub delete_dir_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $directory_name = $env{'form.currentpath'};
$directory_name =~ s|/$||; # remove any trailing slash
- my ($uname,$udom) = &get_name_dom($group);
- my $namespace = &get_namespace($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $namespace = &get_namespace();
+ my $port_path = &get_port_path();
my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
$directory_name);
@@ -476,35 +558,35 @@ sub delete_dir_confirmed {
}
$env{'form.currentpath'} = $directory_name;
}
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
}
sub rename {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
- my ($uname,$udom) = &get_name_dom($group);
- $file_name = &prepend_group($file_name,$group);
+ my ($uname,$udom) = &get_name_dom();
+ $file_name = &prepend_group($file_name);
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));
} else {
&open_form($r,$url);
$r->print(''.&mt('Rename').' '.&display_file().' to
?
');
- &close_form($r,$url,$group);
+ &close_form($r,$url);
}
}
sub rename_confirmed {
- my ($r,$url,$group)=@_;
+ my ($r,$url)=@_;
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
if ($filenewname eq '') {
$r->print(''.
&mt("Error: no valid filename was provided to rename to.").
'
');
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
return;
}
my $result=
@@ -522,33 +604,25 @@ sub rename_confirmed {
''.&display_file('',$env{'form.filenewname'}).'',
''.&display_file('',$filenewname).''));
}
- $r->print(&done(undef,$url,$group));
+ $r->print(&done(undef,$url));
}
sub display_access {
- my ($r,$url,$group,$can_setacl) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ my ($r,$url,$group,$can_setacl,$port_path) = @_;
+ my ($uname,$udom) = &get_name_dom();
my $file_name = $env{'form.currentpath'}.$env{'form.access'};
- $file_name = &prepend_group($file_name,$group);
+ $file_name = &prepend_group($file_name);
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]',$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 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 ($group eq '') {
+ $info .= (&mt("Direct others to the 'Display file listing' link (shown when there are viewable files) on your personal information page:
http://$ENV{'SERVER_NAME'}/adm/$udom/$uname/aboutme"));
+ }
+
if ($can_setacl) {
&open_form($r,$url);
$r->print($header.$info);
@@ -557,19 +631,18 @@ sub display_access {
'continue' => &mt('Proceed'),
'cancel' => &mt('Back to directory listing'),
};
- &close_form($r,$url,$group,$button_text);
+ &close_form($r,$url,$button_text);
} else {
$r->print($header);
if ($aclcount) {
$r->print($info);
}
- &view_access_settings($r,$url,$group,$access_controls{$file_name},
- $aclcount);
+ &view_access_settings($r,$url,$access_controls{$file_name},$aclcount);
}
}
sub view_access_settings {
- my ($r,$url,$group,$access_controls,$aclcount) = @_;
+ my ($r,$url,$access_controls,$aclcount) = @_;
my ($showstart,$showend);
my %todisplay;
foreach my $key (sort(keys(%{$access_controls}))) {
@@ -590,12 +663,8 @@ 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;
- }
$r->print('
'.&mt('Return to directory listing').'');
+ &group_args().'">'.&mt('Return to directory listing').'');
return;
}
@@ -703,7 +772,7 @@ sub build_access_summary {
sub update_access {
- my ($r,$url,$group) = @_;
+ my ($r,$url,$group,$port_path) = @_;
my $totalprocessed = 0;
my %processing;
my %title = (
@@ -728,10 +797,10 @@ sub update_access {
}
}
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $r->print(''.&mt('Allowing others to retrieve portfolio file: [_1]',
- $file_name).'
'."\n");
- $file_name = &prepend_group($file_name,$group);
- my ($uname,$udom) = &get_name_dom($group);
+ $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();
my ($errors,$outcome,$deloutcome,$new_values,$translation);
if ($totalprocessed) {
($outcome,$deloutcome,$new_values,$translation) =
@@ -802,7 +871,7 @@ sub update_access {
if ($allnew > 0) {
my $now = time;
my $then = $now + (60*60*24*180); # six months approx.
- &open_form($r,$url,$group);
+ &open_form($r,$url);
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'}).'
');
@@ -817,15 +886,14 @@ sub update_access {
$access_controls{$file_name},$now,$then);
}
}
- &close_form($r,$url,$group);
+ &close_form($r,$url);
} else {
- my $group_arg;
- if ($group) {
- $group_arg = '&group='.$group;
- }
$r->print('
'.
- &mt('Display all access settings for this file').'');
+ '¤tpath='.$env{'form.currentpath'}.&group_args().'">'.
+ &mt('Display all access settings for this file').''.
+ ' '.
+ ''.&mt('Return to directory listing').'');
}
return;
}
@@ -995,25 +1063,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(' |
');
}
@@ -1394,7 +1461,7 @@ END_SCRIPT
}
sub select_files {
- my ($r,$group) = @_;
+ my ($r) = @_;
if ($env{'form.continue'} eq 'true') {
# here we update the selections for the currentpath
# eventually, have to handle removing those not checked, but . . .
@@ -1438,6 +1505,7 @@ ENDSMP
}
}
}
+
sub upload {
my ($r,$url,$group)=@_;
my $fname=$env{'form.uploaddoc.filename'};
@@ -1453,22 +1521,19 @@ sub upload {
}
$fname=&Apache::lonnet::clean_filename($fname);
- my $portfolio_root=&get_portfolio_root($group);
- my ($uname,$udom) = &get_name_dom($group);
- my $port_path = &get_port_path($group);
+ my $portfolio_root=&get_portfolio_root();
+ my ($uname,$udom) = &get_name_dom();
+ my $port_path = &get_port_path();
# Fixme --- Move the checking for existing file to LOND error return
- my @dir_list=&get_dir_list($portfolio_root,$group);
+ my @dir_list=&get_dir_list($portfolio_root);
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,$group);
+ $file_name = &prepend_group($file_name);
$found_file = 1;
- if (defined($group)) {
- $file_name = $group.'/'.$file_name;
- }
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$locked_file = 1;
}
@@ -1478,17 +1543,17 @@ sub upload {
if (($current_disk_usage + $filesize) > $disk_quota){
$r->print('