';
return $result;
}
sub delete {
- my ($r,$url)=@_;
+ my ($r,$url,$group)=@_;
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));
} else {
if (scalar(@files)) {
&open_form($r,$url);
$r->print('
'.&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.').
'
'.
@@ -564,18 +548,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);
}
}
sub view_access_settings {
- my ($r,$url,$access_controls,$aclcount) = @_;
+ my ($r,$url,$group,$access_controls,$aclcount) = @_;
my ($showstart,$showend);
my %todisplay;
foreach my $key (sort(keys(%{$access_controls}))) {
@@ -596,8 +581,12 @@ 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_arg.'">'.&mt('Return to directory listing').'');
return;
}
@@ -705,7 +694,7 @@ sub build_access_summary {
sub update_access {
- my ($r,$url,$group,$port_path) = @_;
+ my ($r,$url,$group) = @_;
my $totalprocessed = 0;
my %processing;
my %title = (
@@ -731,9 +720,9 @@ 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).''."\n");
+ $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 +793,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 +808,15 @@ 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;
+ }
$r->print(' '.
- &mt('Display all access settings for this file').''.
- ' '.
- ''.&mt('Return to directory listing').'');
+ '¤tpath='.$env{'form.currentpath'}.$group_arg.'">'.
+ &mt('Display all access settings for this file').'');
}
return;
}
@@ -1395,7 +1385,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 . . .
@@ -1423,7 +1413,11 @@ ENDSMP
fileList = fileList + document.forms.checkselect.currentpath.value + document.forms.checkselect[i].value + "," ;
}
}
- opener.document.forms.lonhomework.$env{'form.fieldname'}.value=fileList;
+ opener.document.forms.lonhomework.
+ENDSMP
+ $javascript .= $env{'form.fieldname'};
+ $javascript .= (<
@@ -1439,36 +1433,26 @@ ENDSMP
}
}
}
-
sub upload {
my ($r,$url,$group)=@_;
my $fname=$env{'form.uploaddoc.filename'};
my $filesize = (length($env{'form.uploaddoc'})) / 1000; #express in k (1024?)
my $disk_quota = 20000; # expressed in k
- if (defined($group)) {
- my $grp_quota = &get_group_quota($group); # quota expressed in k
- if ($grp_quota ne '') {
- $disk_quota = $grp_quota;
- } else {
- $disk_quota = 0;
- }
- }
$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 +1465,17 @@ sub upload {
if (($current_disk_usage + $filesize) > $disk_quota){
$r->print('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes). Disk quota will be exceeded.'.
' Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
- $r->print(&done('Back',$url));
+ $r->print(&done('Back',$url,$group));
}
elsif ($found_file){
if ($locked_file){
$r->print(''.'Unable to upload '.$fname.', a locked file by that name was found in '.$port_path.$env{'form.currentpath'}.''.
' You will be able to rename or delete existing '.$fname.' after a grade has been assigned.');
- $r->print(&done('Back',$url));
+ $r->print(&done('Back',$url,$group));
} else {
$r->print(''.'Unable to upload '.$fname.', a file by that name was found in '.$port_path.$env{'form.currentpath'}.''.
' To upload, rename or delete existing '.$fname.' in '.$port_path.$env{'form.currentpath'});
- $r->print(&done('Back',$url));
+ $r->print(&done('Back',$url,$group));
}
} else {
my $result=&Apache::lonnet::userfileupload('uploaddoc','',
@@ -1499,20 +1483,19 @@ sub upload {
if ($result !~ m|^/uploaded/|) {
$r->print(''.'An errror occured ('.$result.
') while trying to upload '.&display_file().' ');
- $r->print(&done('Back',$url));
+ $r->print(&done('Back',$url,$group));
} else {
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group));
}
}
}
-
sub lock_info {
my ($r,$url,$group) = @_;
- my ($uname,$udom) = &get_name_dom();
+ my ($uname,$udom) = &get_name_dom($group);
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my $file_name = $env{'form.lockinfo'};
- $file_name = &prepend_group($file_name);
+ $file_name = &prepend_group($file_name,$group);
if (defined($file_name) && defined($$current_permissions{$file_name})) {
foreach my $array_item (@{$$current_permissions{$file_name}}) {
if (ref($array_item) eq 'ARRAY') {
@@ -1535,22 +1518,21 @@ sub lock_info {
}
}
}
- $r->print(&done('Back',$url));
+ $r->print(&done('Back',$url,$group));
return 'ok';
}
-
sub createdir {
- my ($r,$url)=@_;
+ my ($r,$url,$group)=@_;
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
if ($newdir eq '') {
$r->print(''.
&mt("Error: no directory name was provided.").
' ');
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group));
return;
}
- my $portfolio_root = &get_portfolio_root();
- my @dir_list=&get_dir_list($portfolio_root);
+ my $portfolio_root = &get_portfolio_root($group);
+ my @dir_list=&get_dir_list($portfolio_root,$group);
my $found_file = 0;
foreach my $line (@dir_list) {
my ($filename)=split(/\&/,$line,2);
@@ -1562,8 +1544,8 @@ sub createdir {
$r->print(''.'Unable to create a directory named '.$newdir.
' a file or directory by that name already exists. ');
} else {
- 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);
my $result=&Apache::lonnet::mkdiruserfile($uname,$udom,
$port_path.$env{'form.currentpath'}.$newdir);
if ($result ne 'ok') {
@@ -1574,47 +1556,32 @@ sub createdir {
if ($newdir ne $env{'form.newdir'}) {
$r->print("The new directory name was changed from: ".$env{'form.newdir'}." to $newdir ");
}
- $r->print(&done(undef,$url));
+ $r->print(&done(undef,$url,$group));
}
sub get_portfolio_root {
- my ($uname,$udom) = &get_name_dom();
- my $path;
- if (defined($env{'form.group'})) {
- $path = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';
+ my ($group) = @_;
+ my ($portfolio_root,$udom,$uname,$path);
+ ($uname,$udom) = &get_name_dom($group);
+ if (defined($group)) {
+ $path = '/userfiles/groups/'.$group.'/portfolio';
} else {
$path = '/userfiles/portfolio';
}
return (&Apache::loncommon::propath($udom,$uname).$path);
}
-sub get_group_quota {
- my ($group) = @_;
- my $group_quota;
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
- if (%curr_groups) {
- my %group_info = &Apache::longroup::get_group_settings(
- $curr_groups{$group});
- $group_quota = $group_info{'quota'}; #expressed in Mb
- if ($group_quota) {
- $group_quota = 1000 * $group_quota; #expressed in k
- }
- }
- return $group_quota;
-}
-
sub get_dir_list {
- my ($portfolio_root) = @_;
- my ($uname,$udom) = &get_name_dom();
+ my ($portfolio_root,$group) = @_;
+ my ($uname,$udom) = &get_name_dom($group);
return &Apache::lonnet::dirlist($env{'form.currentpath'},
$udom,$uname,$portfolio_root);
}
sub get_name_dom {
+ my ($group) = @_;
my ($uname,$udom);
- if (defined($env{'form.group'})) {
+ if (defined($group)) {
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$uname = $env{'course.'.$env{'request.course.id'}.'.num'};
} else {
@@ -1625,26 +1592,28 @@ sub get_name_dom {
}
sub prepend_group {
- my ($filename) = @_;
- if (defined($env{'form.group'})) {
- $filename = $env{'form.group'}.$filename;
+ my ($filename,$group) = @_;
+ if (defined($group)) {
+ $filename = $group.$filename;
}
return $filename;
}
sub get_namespace {
+ my ($group) = @_;
my $namespace = 'portfolio';
- if (defined($env{'form.group'})) {
- my ($uname,$udom) = &get_name_dom();
- $namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'};
+ if (defined($group)) {
+ my ($uname,$udom) = &get_name_dom($group);
+ $namespace .= '_'.$udom.'_'.$uname.'_'.$group;
}
return $namespace;
}
sub get_port_path {
+ my ($group) = @_;
my $port_path;
- if (defined($env{'form.group'})) {
- $port_path = "groups/$env{'form.group'}/portfolio";
+ if (defined($group)) {
+ $port_path = "groups/$group/portfolio";
} else {
$port_path = 'portfolio';
}
@@ -1652,7 +1621,7 @@ sub get_port_path {
}
sub missing_priv {
- my ($r,$url,$priv) = @_;
+ my ($r,$url,$priv,$group) = @_;
my $longtext = {
upload => 'upload files',
delete => 'delete files',
@@ -1670,9 +1639,9 @@ sub missing_priv {
$r->print(&mt('
Action disallowed
'));
$r->print(&mt('You do not have sufficient privileges to [_1] ',
$longtext->{$priv}));
- if (defined($env{'form.group'})) {
+ if ($group) {
$r->print(&mt("in the group's file repository."));
- $rtnlink .= &group_args()
+ $rtnlink .= '&group='.$group;
} else {
$r->print(&mt('in this portfolio.'));
}
@@ -1682,30 +1651,6 @@ sub missing_priv {
return;
}
-sub coursegrp_portfolio_header {
- my ($cdom,$cnum,$grp_desc)=@_;
- my $gpterm = &Apache::loncommon::group_term();
- my $ucgpterm = $gpterm;
- $ucgpterm =~ s/^(\w)/uc($1)/e;
- if ($env{'form.ref'}) {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/coursegroups",
- text=>"Groups",
- title=>"Course Groups"});
- }
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/$env{'form.group'}/smppg?ref=$env{'form.ref'}",
- text=>"$ucgpterm: $grp_desc",
- title=>"Go to group's home page"},
- {href=>"/adm/coursegrp_portfolio?".&group_args(),
- text=>"Group Portfolio",
- title=>"Display group portfolio"});
- my $output = &Apache::lonhtmlcommon::breadcrumbs(
- &mt('[_1] portfolio files - [_2]',$gpterm,$grp_desc));
- return $output;
-}
-
-
sub handler {
# this handles file management
my $r = shift;
@@ -1713,7 +1658,7 @@ sub handler {
['selectfile','currentpath','meta','lockinfo','currentfile','action',
'fieldname','mode','rename','continue','group','access','setnum',
'cnum','cdom','type','setroles']);
- my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc);
+ my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title);
if ($r->uri =~ m|^(/adm/)([^/]+)|) {
$url = $1.$2;
$caller = $2;
@@ -1728,21 +1673,18 @@ sub handler {
return HTTP_NOT_ACCEPTABLE;
}
my $earlyout = 0;
- my $view_permission =
- &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
- $env{'form.group'} =~ s/\W//g;
- $group = $env{'form.group'};
+ my $view_permission = &Apache::lonnet::allowed('vcg',
+ $env{'request.course.id'});
+ $group = $env{'form.group'};
+ $group =~ s/\W//g;
if ($group) {
- ($uname,$udom) = &get_name_dom();
+ ($uname,$udom) = &get_name_dom($group);
my %curr_groups = &Apache::longroup::coursegroups($udom,$uname,
$group);
if (%curr_groups) {
- my %grp_content = &Apache::longroup::get_group_settings(
- $curr_groups{$group});
- $grp_desc = &unescape($grp_content{'description'});
if (($view_permission) || (&Apache::lonnet::allowed('rgf',
$env{'request.course.id'}.'/'.$group))) {
- $portfolio_root = &get_portfolio_root();
+ $portfolio_root = &get_portfolio_root($group);
} else {
$r->print('You do not have the privileges required to access the shared files space for this group.');
$earlyout = 1;
@@ -1757,24 +1699,17 @@ sub handler {
$earlyout = 1;
}
if ($earlyout) { return OK; }
- if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ if (&Apache::lonnet::allowed('agf',$env{'request.course.id'}.'/'.$group)) {
+ $can_setacl = 1;
+ }
+ if (&Apache::lonnet::allowed('ugf',$env{'request.course.id'}.'/'.$group)) {
+ $can_upload = 1;
+ }
+ if (&Apache::lonnet::allowed('mgf',$env{'request.course.id'}.'/'.$group)) {
$can_modify = 1;
+ }
+ if (&Apache::lonnet::allowed('dgf',$env{'request.course.id'}.'/'.$group)) {
$can_delete = 1;
- $can_upload = 1;
- $can_setacl = 1;
- } else {
- if (&Apache::lonnet::allowed('agf',$env{'request.course.id'}.'/'.$group)) {
- $can_setacl = 1;
- }
- if (&Apache::lonnet::allowed('ugf',$env{'request.course.id'}.'/'.$group)) {
- $can_upload = 1;
- }
- if (&Apache::lonnet::allowed('mgf',$env{'request.course.id'}.'/'.$group)) {
- $can_modify = 1;
- }
- if (&Apache::lonnet::allowed('dgf',$env{'request.course.id'}.'/'.$group)) {
- $can_delete = 1;
- }
}
} else {
($uname,$udom) = &get_name_dom();
@@ -1786,7 +1721,6 @@ sub handler {
$can_setacl = 1;
}
- my $port_path = &get_port_path();
&Apache::loncommon::no_cache($r);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -1812,7 +1746,7 @@ sub handler {
&open_form($r,$url);
# $r->print(&edit_meta_data($r, $env{'form.currentpath'}.$env{'form.selectfile'}));
$r->print('Edit the meta data ');
- &close_form($r,$url);
+ &close_form($r,$url,$group);
}
if ($env{'form.store'}) {
}
@@ -1821,67 +1755,67 @@ sub handler {
if ($can_upload) {
&upload($r,$url,$group);
} else {
- &missing_priv($r,$url,'upload');
+ &missing_priv($r,$url,'upload',$group),
}
} elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
if ($can_delete) {
- &delete_confirmed($r,$url);
+ &delete_confirmed($r,$url,$group);
} else {
- &missing_priv($r,$url,'delete');
+ &missing_priv($r,$url,'delete',$group);
}
} elsif ($env{'form.action'} eq 'delete') {
if ($can_delete) {
- &delete($r,$url);
+ &delete($r,$url,$group);
} else {
- &missing_priv($r,$url,'delete');
+ &missing_priv($r,$url,'delete',$group);
}
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) {
if ($can_delete) {
- &delete_dir_confirmed($r,$url);
+ &delete_dir_confirmed($r,$url,$group);
} else {
- &missing_priv($r,$url,'delete');
+ &missing_priv($r,$url,'delete',$group);
}
} elsif ($env{'form.action'} eq 'deletedir') {
if ($can_delete) {
- &delete_dir($r,$url);
+ &delete_dir($r,$url,$group);
} else {
- &missing_priv($r,$url,'delete');
+ &missing_priv($r,$url,'delete',$group);
}
} elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
if ($can_modify) {
- &rename_confirmed($r,$url);
+ &rename_confirmed($r,$url,$group);
} else {
- &missing_priv($r,$url,'rename');
+ &missing_priv($r,$url,'rename',$group);
}
} elsif ($env{'form.rename'}) {
$env{'form.selectfile'} = $env{'form.rename'};
$env{'form.action'} = 'rename';
if ($can_modify) {
- &rename($r,$url);
+ &rename($r,$url,$group);
} else {
- &missing_priv($r,$url,'rename');
+ &missing_priv($r,$url,'rename',$group);
}
} elsif ($env{'form.access'}) {
$env{'form.selectfile'} = $env{'form.access'};
$env{'form.action'} = 'chgaccess';
- &display_access($r,$url,$group,$can_setacl,$port_path);
+ &display_access($r,$url,$group,$can_setacl);
} elsif ($env{'form.action'} eq 'chgaccess') {
if ($can_setacl) {
- &update_access($r,$url,$group,$port_path);
+ &update_access($r,$url,$group);
} else {
- &missing_priv($r,$url,'setacl');
+ &missing_priv($r,$url,'setacl',$group);
}
} elsif ($env{'form.action'} eq 'rolepicker') {
if ($can_setacl) {
&role_options_window($r);
} else {
- &missing_priv($r,$url,'setacl');
+ &missing_priv($r,$url,'setacl',$group);
}
} elsif ($env{'form.createdir'}) {
if ($can_upload) {
- &createdir($r,$url);
+ &createdir($r,$url,$group);
} else {
- &missing_priv($r,$url,'upload');
+ &missing_priv($r,$url,'upload',$group);
}
} elsif ($env{'form.lockinfo'}) {
&lock_info($r,$url,$group);
@@ -1890,18 +1824,14 @@ sub handler {
if ($env{'form.currentpath'}) {
$current_path = $env{'form.currentpath'};
}
- if ($caller eq 'coursegrp_portfolio') {
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- $r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc));
- }
- my @dir_list=&get_dir_list($portfolio_root);
+ my @dir_list=&get_dir_list($portfolio_root,$group);
if ($dir_list[0] eq 'no_such_dir'){
# two main reasons for this:
# 1) never been here, so directory structure not created
# 2) back-button navigation after deleting a directory
if ($current_path eq '/'){
&Apache::lonnet::mkdiruserfile($uname,$udom,
- &get_port_path());
+ &get_port_path($group));
} else {
# some directory that snuck in get rid of the directory
# from the recent pulldown, just in case
@@ -1915,8 +1845,8 @@ sub handler {
}
# need to know if directory is empty so it can be removed if desired
my $is_empty=(@dir_list == 2);
- &display_common($r,$url,$current_path,$is_empty,\@dir_list,
- $can_upload);
+ &display_common($r,$url,$current_path,$is_empty,\@dir_list,$group,
+ $can_upload);
&display_directory($r,$url,$current_path,$is_empty,\@dir_list,$group,
$can_upload,$can_modify,$can_delete,$can_setacl);
$r->print(&Apache::loncommon::end_page());