'.
- '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 %versioned;
- foreach my $line (sort
+ foreach my $dir_line (sort
{
my ($afile)=split('&',$a,2);
my ($bfile)=split('&',$b,2);
@@ -193,18 +271,44 @@ 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.",";
+ my $fullpath = &prepend_group($current_path.$fname.'.'.$extension);
+ push(@{ $versioned{$fullpath} },
+ [$filename,$dom,$testdir,$size,$mtime,$obs,]);
+ } 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;
+ my $fullpath = &prepend_group($current_path.$filename);
+ if ($env{'form.showversions'} eq $filename) {
+ $show_versions = 'true';
+ }
+ if (exists($versioned{$fullpath})) {
+ my %anchor_fields = (
+ 'selectfile' => $fullpath,
+ 'continue' => 'false',
+ 'currentpath' => $current_path,
+ );
+ if ($show_versions) {
+ $version_flag = &make_anchor('portfolio',\%anchor_fields,
+ ' ');
+ } else {
+ $anchor_fields{'showversions'} = $filename;
+ $version_flag = &make_anchor('portfolio',\%anchor_fields,
+ ' ');
+ }
+ } else {
+ $version_flag = ' ';
+ }
if ($dirptr&$testdir) {
my $colspan='colspan="2"';
if ($select_mode eq 'true'){
@@ -212,19 +316,18 @@ 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).' ');
+ my %anchor_fields = (
+ 'selectfile' => $filename.'/',
+ 'currentpath' => $current_path.$filename.'/',
+ 'mode' => $env{"form.mode"},
+ 'fieldname' => $env{"form.fieldname"},
+ 'continue' => $env{"form.continue"}
+ );
+ $r->print(''.$version_flag.' '.&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);
if ($select_mode eq 'true') {
$line=' ';
} else {
if (exists $locked_files{$fullpath}) {
- $line.='Locked ';
+ my %anchor_fields = (
+ 'lockinfo' => $fullpath
+ );
+ $line.=''.&make_anchor($url,\%anchor_fields,'Locked').' ';
$css_class= 'LC_browser_file_locked';
} else {
if (!$can_modify) {
@@ -245,16 +351,19 @@ sub display_directory {
$line .= ' ';
}
if ($can_modify) {
- my $cat=' ';
- $line .= 'Rename ';
- $line .= ''.$cat.' ';
+ my %anchor_fields = (
+ 'rename' => $filename,
+ currentpath => $current_path
+ );
+ $line .= &make_anchor($url,\%anchor_fields,'Rename');
+ $line .= ''.&make_anchor($href_edit_location.$filename.'.meta',\%anchor_fields,$cat);
+ # ''.$cat.' ';
}
$line .= ' ';
}
}
- $r->print('');
- $r->print($line);
my $curr_access;
if ($select_mode ne 'true') {
my $pub_access = 0;
@@ -288,19 +397,19 @@ 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, $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 (@{ $versioned{$fullpath} }) {
+ my ($v_filename,$dom,$testdir,$size,$mtime,$obs) =
+ @$dir_line;
+ $line = ' ';
+ &display_directory_line($r,$select_mode, $v_filename, $mtime, $size,
+ $css_class, $line, \%access_controls, $curr_access, $now,
+ undef, $href_location, $url, $current_path, $access_admin_text, 1);
+ }
}
- $r->print(' '.$/);
}
}
}
@@ -342,7 +451,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'),
@@ -350,19 +459,12 @@ sub close_form {
};
}
$r->print(' ');
- if (defined($group)) {
- $r->print("\n".' ');
- }
- $r->print('
');
+ $r->print(&group_form_data().'');
$r->print('');
}
@@ -389,49 +491,47 @@ sub display_file {
}
sub done {
- my ($message,$url,$group)=@_;
+ my ($message,$url)=@_;
unless (defined $message) {
$message='Done';
}
- my $result = '';
+ my %anchor_fields = (
+ 'currentpath' => $env{'form.currentpath'},
+ 'fieldname' => $env{'form.fieldname'},
+ 'mode' => $env{'form.mode'}
+ );
+ my $result = ''.&make_anchor($url,\%anchor_fields,&mt($message)).' ';
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'}.
@@ -441,23 +541,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);
@@ -477,35 +577,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=
@@ -523,35 +623,29 @@ 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,$port_path) = @_;
- my ($uname,$udom) = &get_name_dom($group);
+ 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]',
- $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 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.');
+ $info .= ''.&mt('Public files are available to anyone without the need for login.');
+ $info .= ' '.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.');
+ $info .= ' '.&mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satisfy the conditions you set.').' ';
+ $info .= &mt('The conditions can include affiliation with a particular course or group, or a user account in a specific domain.').' ';
+ $info .= &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);
@@ -560,19 +654,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}))) {
@@ -593,12 +686,10 @@ 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').' ');
+ my %anchor_fields = (
+ 'currentpath' => $env{'form.currentpath'}
+ );
+ $r->print(' '.&make_anchor($url, \%anchor_fields, &mt('Return to directory listing')));
return;
}
@@ -731,10 +822,10 @@ sub update_access {
}
}
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
- $r->print(''.&mt('Allowing others to retrieve portfolio file: [_1]',
+ $r->print(''.&mt('Allowing others to retrieve file: [_1]',
$port_path.$file_name).' '."\n");
- $file_name = &prepend_group($file_name,$group);
- my ($uname,$udom) = &get_name_dom($group);
+ $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) =
@@ -805,7 +896,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'}).' ');
@@ -820,18 +911,15 @@ 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').' '.
- ' '.
- ''.&mt('Return to directory listing').' ');
+ my %anchor_fields = (
+ 'currentpath' => $env{'form.currentpath'},
+ 'access' => $env{'form.selectfile'}
+ );
+ $r->print(' '.&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 listing')));
}
return;
}
@@ -1001,25 +1089,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('
');
}
@@ -1400,7 +1487,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 . . .
@@ -1444,6 +1531,7 @@ ENDSMP
}
}
}
+
sub upload {
my ($r,$url,$group)=@_;
my $fname=$env{'form.uploaddoc.filename'};
@@ -1459,22 +1547,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;
}
@@ -1484,17 +1569,17 @@ sub upload {
if (($current_disk_usage + $filesize) > $disk_quota){
$r->print('