-
- $text{'upload_label'}
- |
- $groupitem
+ my $escuri = &HTML::Entities::encode($r->uri,'&<>"');
+ $r->print(<<"TABLE");
+
+
+
+ $text{'upload_label'}
+ |
+
+ |
-
-
-
+
+
+
TABLE
+ }
my @tree = split (/\//,$current_path);
- $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/');
+ $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/');
if (@tree > 1){
my $newCurrentPath = '';
for (my $i = 1; $i< @tree; $i++){
@@ -106,11 +117,11 @@ TABLE
$r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/');
}
}
- $r->print('');
+ $r->print('');
&Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path);
- $r->print(' ");
}
sub display_directory {
- my ($r,$url,$current_path,$is_empty,$dir_list,$group)=@_;
+ my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
+ $can_modify,$can_delete,$can_setacl)=@_;
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my ($groupitem,$groupecho);
my $display_out;
@@ -126,10 +138,15 @@ sub display_directory {
my $checked_files;
my $port_path = &get_port_path($group);
my ($uname,$udom) = &get_name_dom($group);
- if (defined($group)) {
+ my $access_admin_text = &mt('View Status');
+ if ($can_setacl) {
+ $access_admin_text = &mt('View/Change Status');
+ }
+ if ((defined($group)) && (defined($env{'request.course.id'}))) {
$groupitem = '';
$groupecho = '&group='.$group;
}
+
my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
$uname);
my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash(
@@ -141,7 +158,7 @@ sub display_directory {
$checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
$select_mode = 'true';
}
- if ($is_empty && ($current_path ne '/')) {
+ if ($is_empty && ($current_path ne '/') && $can_delete) {
$display_out = ' | ');
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $count ++;
+ }
+ }
+}
+
+
sub update_access {
my ($r,$url,$group) = @_;
- my $function = &Apache::loncommon::get_users_function();
- my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
my $totalprocessed = 0;
my %processing;
my %title = (
@@ -547,16 +743,18 @@ sub update_access {
my $updated_controls = $access_controls{$file_name};
my ($showstart,$showend);
$r->print(&Apache::loncommon::start_data_table());
- $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(''.&mt('Type of change').' | '.
&mt('Access control').' | '.&mt('Dates available').
' | '.&mt('Additional information').' | ');
- $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table_header_row());
foreach my $chg (sort(keys(%processing))) {
if (@{$processing{$chg}} > 0) {
if ($chg eq 'delete') {
if (!($deloutcome eq 'ok')) {
- $errors .= &mt('A problem occurred deleting access controls: [_1]',$deloutcome);
+ $errors .=''.
+ &mt('A problem occurred deleting access controls: [_1]',$deloutcome).
+ '';
next;
}
}
@@ -565,100 +763,24 @@ sub update_access {
$r->print(''.&mt($title{$chg}).
'. | ');
my $count = 0;
+ my %todisplay;
foreach my $key (sort(keys(%{$$changes{$chg}}))) {
- if ($count) {
- $r->print(&Apache::loncommon::start_data_table_row());
- }
- my ($num,$scope,$end,$start) = &unpack_acc_key($key);
+ my ($num,$scope,$end,$start) = &unpack_acc_key($key);
my $newkey = $key;
if ($chg eq 'activate') {
$newkey =~ s/^(\d+)/$$translation{$1}/;
}
- my $content = $$updated_controls{$newkey};
- if ($chg eq 'delete') {
- $showstart = &mt('Deleted');
- $showend = $showstart;
- } else {
- $showstart = localtime($start);
- if ($end == 0) {
- $showend = &mt('No end date');
- } else {
- $showend = localtime($end);
- }
- }
- $r->print(''.&mt($scope));
- if (($scope eq 'course') || ($scope eq 'group')) {
- if ($chg ne 'delete') {
- my $cid = $content->{'domain'}.'_'.$content->{'number'};
- my %course_description = &Apache::lonnet::coursedescription($cid);
- $r->print(' ('.$course_description{'description'}.')');
- }
- }
- $r->print(' | '.&mt('Start: ').$showstart.
- ' '.&mt('End: ').$showend.' | ');
- if ($chg ne 'delete') {
- if ($scope eq 'guest') {
- $r->print(&mt('Password').': '.$content->{'password'});
- } elsif ($scope eq 'course' || $scope eq 'group') {
- $r->print('');
- $r->print(''.&mt('Roles').' | '.
- &mt('Access').' | '.
- &mt('Sections').' | ');
- if ($scope eq 'course') {
- $r->print(''.&mt('Groups').' | ');
- } else {
- $r->print(''.&mt('Teams').' | ');
- }
- $r->print(' ');
- foreach my $id (sort(keys(%{$content->{'roles'}}))) {
- $r->print('');
- foreach my $item ('role','access','section','group') {
- $r->print('');
- if ($item eq 'role') {
- my $ucscope = $scope;
- $ucscope =~ s/^(\w)/uc($1)/;
- my $role_output;
- foreach my $role (@{$content->{'roles'}{$id}{$item}}) {
- if ($role eq 'all') {
- $role_output .= $role.',';
- } elsif ($role =~ /^cr/) {
- $role_output .= (split('/',$role))[3].',';
- } else {
- $role_output .= &Apache::lonnet::plaintext($role,$ucscope).',';
- }
- }
- $role_output =~ s/,$//;
- $r->print($role_output);
- } else {
- $r->print(join(',',@{$content->{'roles'}{$id}{$item}}));
- }
- $r->print(' | ');
- }
- }
- $r->print(&Apache::loncommon::end_data_table_row());
- $r->print(&Apache::loncommon::end_data_table());
- } elsif ($scope eq 'domains') {
- $r->print(&mt('Domains: ').join(',',@{$content->{'dom'}}));
- } elsif ($scope eq 'users') {
- my $curr_user_list = &sort_users($content->{'users'});
- $r->print(&mt('Users: ').$curr_user_list);
- } else {
- $r->print(' ');
- }
- } else {
- $r->print(' ');
- }
- $r->print('');
- $r->print(&Apache::loncommon::end_data_table_row());
- $count ++;
+ $todisplay{$scope}{$newkey} = $$updated_controls{$newkey};
}
+ &build_access_summary($r,$count,$chg,%todisplay);
}
}
$r->print(&Apache::loncommon::end_data_table());
} else {
if ((@{$processing{'activate'}} > 0) || (@{$processing{'update'}} > 0)) {
- $errors .= &mt('A problem occurred storing access control settings: [_1]',$outcome);
+ $errors .= ''.
+ &mt('A problem occurred storing access control settings: [_1]',$outcome).
+ '';
}
}
if ($errors) {
@@ -692,8 +814,12 @@ sub update_access {
}
&close_form($r,$url,$group);
} else {
+ my $group_arg;
+ if ($group) {
+ $group_arg = '&group='.$group;
+ }
$r->print(' '.
+ '¤tpath='.$env{'form.currentpath'}.$group_arg.'">'.
&mt('Display all access settings for this file').'');
}
return;
@@ -830,9 +956,9 @@ sub access_setting_table {
$r->print('');
$r->print(''.&mt('Public access:').' '.$publictext.'');
$r->print(&Apache::loncommon::start_data_table());
- $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(' | '.&mt('Action').' | '.&mt('Dates available').' | ');
- $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table_header_row());
$r->print(&Apache::loncommon::start_data_table_row());
if ($public) {
$r->print(''.&actionbox('old',$publicnum,'public').' | '.
@@ -844,12 +970,12 @@ sub access_setting_table {
$r->print(&Apache::loncommon::end_data_table_row());
$r->print(&Apache::loncommon::end_data_table());
$r->print(' | | ');
- $r->print(''.&mt('Password-protected access:').' '.$guesttext.'');
+ $r->print(''.&mt('Passphrase-protected access:').' '.$guesttext.'');
$r->print(&Apache::loncommon::start_data_table());
- $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_header_row());
$r->print(' | '.&mt('Action').' | '.&mt('Dates available').
- ' | '. &mt('Password').' | ');
- $r->print(&Apache::loncommon::end_data_table_row());
+ ''. &mt('Passphrase').' | ');
+ $r->print(&Apache::loncommon::end_data_table_header_row());
$r->print(&Apache::loncommon::start_data_table_row());
my $passwd;
if ($guest) {
@@ -921,40 +1047,38 @@ sub display_access_row {
my ($r,$status,$type,$items,$access_controls,$now,$then) = @_;
if (@{$items} > 0) {
my @all_doms;
- my $tablecolor;
my $colspan = 3;
my $uctype = $type;
$uctype =~ s/^(\w)/uc($1)/e;
$r->print(&Apache::loncommon::start_data_table());
- $r->print(&Apache::loncommon::start_data_table_row());
- $r->print(''.&mt('Action?').' | '.&mt($uctype).' | '.
+ $r->print(&Apache::loncommon::start_data_table_header_row());
+ $r->print(' | '.&mt('Action?').' | '.&mt($uctype).' | '.
&mt('Dates available').' | ');
if (($type eq 'course') || ($type eq 'group')) {
$r->print(''.&mt('Allowed [_1] member affiliations',$type).
' | ');
$colspan ++;
- my $function = &Apache::loncommon::get_users_function();
- $tablecolor=&Apache::loncommon::designparm($function.'.tabbg');
} elsif ($type eq 'domains') {
@all_doms = &Apache::loncommon::get_domains();
}
- $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table_header_row());
foreach my $key (@{$items}) {
+ $r->print(&Apache::loncommon::start_data_table_row());
if (($type eq 'course') || ($type eq 'group')) {
- &course_row($r,$status,$type,$key,$access_controls,
- $tablecolor,$now,$then);
+ &course_row($r,$status,$type,$key,$access_controls,$now,$then);
} elsif ($type eq 'domains') {
&domains_row($r,$status,$key,\@all_doms,$access_controls,$now,
$then);
} elsif ($type eq 'users') {
&users_row($r,$status,$key,$access_controls,$now,$then);
}
+ $r->print(&Apache::loncommon::end_data_table_row());
}
- $r->print(&Apache::loncommon::end_data_table_row());
- $r->print(&Apache::loncommon::start_data_table_row());
if ($status eq 'old') {
+ $r->print(&Apache::loncommon::start_data_table_row());
$r->print(''.&additional_item($type).
' | ');
+ $r->print(&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table());
} else {
@@ -964,15 +1088,8 @@ sub display_access_row {
return;
}
-sub course_row {
- my ($r,$status,$type,$item,$access_controls,$tablecolor,$now,$then) = @_;
- my %content;
- my $defdom = $env{'user.domain'};
- if ($status eq 'old') {
- $defdom = $$access_controls{$item}{'domain'};
- }
- $r->print(&Apache::loncommon::coursebrowser_javascript($defdom));
- $r->print(qq|
+sub course_js {
+ return qq|
-|);
- $r->print(&Apache::loncommon::start_data_table_row());
+|;
+}
+
+sub course_row {
+ my ($r,$status,$type,$item,$access_controls,$now,$then) = @_;
+ my $content;
+ my $defdom = $env{'user.domain'};
+ if ($status eq 'old') {
+ $content = $$access_controls{$item};
+ $defdom = $content->{'domain'};
+ }
+ my $js = &Apache::loncommon::coursebrowser_javascript($defdom)
+ .&course_js();
my $crsgrptext = 'Groups';
if ($type eq 'group') {
$crsgrptext = 'Teams';
}
+ my $uctype = $type;
+ $uctype =~ s/^(\w)/uc($1)/e;
my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
$type);
- $r->print(''.&actionbox($status,$num,$scope).' | ');
+ $r->print(''.$js.&actionbox($status,$num,$scope).' | ');
if ($status eq 'old') {
- my $cid = $content{'domain'}.'_'.$content{'number'};
+ my $cid = $content->{'domain'}.'_'.$content->{'number'};
my %course_description = &Apache::lonnet::coursedescription($cid);
- $r->print(''.$course_description{'description'}.' | ');
+ $r->print(''.$course_description{'description'}.' | ');
} elsif ($status eq 'new') {
- my $uctype = $type;
- $uctype =~ s/^(\w)/uc($1)/e;
$r->print(''.&Apache::loncommon::selectcourse_link('portform','crsnum_'.$num,'crsdom_'.$num,'description_'.$num,undef,undef,$uctype).' | ');
}
$r->print(''.&dateboxes($num,$start,$end).' | ');
- $r->print('');
+ $r->print('');
$r->print(''.&mt('Action').' | '.&mt('Roles').' | '.
&mt('Access').' | '.&mt('Sections').' | '.
&mt($crsgrptext).' | ');
if ($status eq 'old') {
my $max_id = 0;
- foreach my $role_id (sort(keys(%{$content{'roles'}}))) {
+ foreach my $role_id (sort(keys(%{$content->{'roles'}}))) {
if ($role_id > $max_id) {
$max_id = $role_id;
}
$max_id ++;
- my $role_selects = &role_selectors($num,$role_id,$status,$type,\%content,'display');
- $r->print('
| '.$role_selects.' ');
+ my $role_selects = &role_selectors($num,$role_id,$status,$type,$content,'display');
+ $r->print('
| '.$role_selects.' ');
}
- $r->print('
'.&mt('Add a roles-based condition').' | ');
+ $r->print('
'.&mt('Add a roles-based condition').' {'domain'}','$content->{'number'}','$uctype'".')" value="'.$max_id.'" /> | ');
} elsif ($status eq 'new') {
my $role_id = 1;
my $role_selects = &role_selectors($num,$role_id,$status,$type,undef,'display');
$r->print('
---|
'.&mt('Add').' | '.$role_selects);
$r->print(' ');
}
- $r->print(&Apache::loncommon::end_data_table_row());
return;
}
sub domains_row {
my ($r,$status,$item,$all_doms,$access_controls,$now,$then) = @_;
- $r->print(&Apache::loncommon::start_data_table_row());
my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
'domains');
- my $dom_select = ''.
+ my $dom_select = '';
$r->print(''.&actionbox($status,$num,$scope).' | '.$dom_select.
' | '.&dateboxes($num,$start,$end).' | ');
- $r->print(&Apache::loncommon::end_data_table_row());
- $r->print(&Apache::loncommon::start_data_table_row());
}
sub users_row {
my ($r,$status,$item,$access_controls,$now,$then) = @_;
- $r->print(&Apache::loncommon::start_data_table_row());
my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
'users');
my $curr_user_list;
@@ -1096,7 +1219,6 @@ sub users_row {
$curr_user_list = &sort_users($content->{'users'});
}
$r->print(''.&actionbox($status,$num,$scope).' | '.&mt("Format for users' username:domain information:").' sparty:msu,illini:uiuc ... etc.
| '.&dateboxes($num,$start,$end).' | ');
- $r->print(&Apache::loncommon::end_data_table_row());
}
sub additional_item {
@@ -1107,17 +1229,17 @@ sub additional_item {
sub actionbox {
my ($status,$num,$scope) = @_;
- my $output = ' '.
''.&mt('Update');
}
- $output .= '';
+ $output .= '';
return $output;
}
@@ -1132,10 +1254,10 @@ sub dateboxes {
undef,undef,1);
my $enddate = &Apache::lonhtmlcommon::date_setter('portform',
'enddate_'.$num,$end,undef,undef,undef,1,undef,
- undef,undef,1). ' '.
+ undef,undef,1). ' '.
''.&mt('No end date').
- '';
+ '';
my $output = &mt('Start: ').$startdate.' '.&mt('End: ').$enddate;
return $output;
@@ -1176,8 +1298,10 @@ sub role_selectors {
$cdom = $env{'form.cdom'};
$cnum = $env{'form.cnum'};
}
+ my $uctype = $type;
+ $uctype =~ s/^(\w)/uc($1)/e;
my ($sections,$groups,$allroles,$rolehash,$accesshash) =
- &Apache::loncommon::get_secgrprole_info($cdom,$cnum,1,$type);
+ &Apache::loncommon::get_secgrprole_info($cdom,$cnum,1,$uctype);
if (!@{$sections}) {
@{$sections} = ('none');
} else {
@@ -1235,6 +1359,10 @@ sub role_options_window {
my $cnum = $env{'form.cnum'};
my $type = $env{'form.type'};
my $addindex = $env{'form.setroles'};
+ my $grouptitle = 'Groups';
+ if ($type eq 'Group') {
+ $grouptitle = 'Teams';
+ }
my $role_selects = &role_selectors(1,1,'new',$type,undef,'rolepicker');
$r->print(<<"END_SCRIPT");
END_SCRIPT
$r->print(&mt('Select roles, course status, section(s) and group(s) for users who will be able to access the portfolio file.'));
- $r->print(''.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt('Groups').' |
---|
'.$role_selects.'
');
+ $r->print(''.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt($grouptitle).' |
---|
'.$role_selects.'
');
return;
}
@@ -1278,7 +1406,7 @@ sub select_files {
$java_files.=',';
}
my $javascript =(<
+
@@ -1313,6 +1437,14 @@ sub upload {
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($group);
@@ -1338,17 +1470,17 @@ sub upload {
}
my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$portfolio_root);
if (($current_disk_usage + $filesize) > $disk_quota){
- $r->print('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes). Disk quota will be exceeded.'.
+ $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,$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'}.''.
+ $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,$group));
} else {
- $r->print('Unable to upload '.$fname.', a file by that name was found in '.$port_path.$env{'form.currentpath'}.''.
+ $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,$group));
}
@@ -1356,14 +1488,15 @@ sub upload {
my $result=&Apache::lonnet::userfileupload('uploaddoc','',
$port_path.$env{'form.currentpath'});
if ($result !~ m|^/uploaded/|) {
- $r->print(' An errror occured ('.$result.
- ') while trying to upload '.&display_file().' ');
+ $r->print(''.'An errror occured ('.$result.
+ ') while trying to upload '.&display_file().' ');
$r->print(&done('Back',$url,$group));
} else {
$r->print(&done(undef,$url,$group));
}
}
}
+
sub lock_info {
my ($r,$url,$group) = @_;
my ($uname,$udom) = &get_name_dom($group);
@@ -1400,9 +1533,9 @@ sub createdir {
my ($r,$url,$group)=@_;
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
if ($newdir eq '') {
- $r->print(''.
+ $r->print(''.
&mt("Error: no directory name was provided.").
- ' ');
+ ' ');
$r->print(&done(undef,$url,$group));
return;
}
@@ -1416,16 +1549,16 @@ sub createdir {
}
}
if ($found_file){
- $r->print(' Unable to create a directory named '.$newdir.
- ' a file or directory by that name already exists. ');
+ $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($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') {
- $r->print(' An errror occured ('.$result.
- ') while trying to create a new directory '.&display_file().' ');
+ $r->print(''.'An errror occured ('.$result.
+ ') while trying to create a new directory '.&display_file().' ');
}
}
if ($newdir ne $env{'form.newdir'}) {
@@ -1446,6 +1579,23 @@ sub get_portfolio_root {
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,$group) = @_;
my ($uname,$udom) = &get_name_dom($group);
@@ -1469,7 +1619,7 @@ sub get_name_dom {
sub prepend_group {
my ($filename,$group) = @_;
if (defined($group)) {
- $filename = $group.'/'.$filename;
+ $filename = $group.$filename;
}
return $filename;
}
@@ -1495,18 +1645,68 @@ sub get_port_path {
return $port_path;
}
+sub missing_priv {
+ my ($r,$url,$priv,$group) = @_;
+ my $longtext = {
+ upload => 'upload files',
+ delete => 'delete files',
+ rename => 'rename files',
+ setacl => 'set access controls for files',
+ };
+ my $escpath = &HTML::Entities::encode($env{'form.currentpath'},'&<>"');
+ my $rtnlink = 'print(&mt('in this portfolio.'));
+ }
+ $rtnlink .= '">'.&mt('Return to directory listing page').'';
+ $r->print(' '.$rtnlink);
+ $r->print(&Apache::loncommon::end_page());
+ return;
+}
+
+sub coursegrp_portfolio_header {
+ my ($cdom,$cnum,$group,$grp_desc)=@_;
+ my $gpterm = &Apache::loncommon::group_term();
+ my $ucgpterm = $gpterm;
+ $ucgpterm =~ s/^(\w)/uc($1)/e;
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/$cdom/$cnum/$group/smppg",
+ text=>"$ucgpterm: $grp_desc",
+ title=>"Go to group's home page"},
+ {href=>"//?group=$group",
+ 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;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['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);
+ 'cnum','cdom','type','setroles','showversions']);
+ my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc);
if ($r->uri =~ m|^(/adm/)([^/]+)|) {
$url = $1.$2;
$caller = $2;
}
+ my ($can_modify,$can_delete,$can_upload,$can_setacl);
if ($caller eq 'coursegrp_portfolio') {
# Needs to be in a course
if (! ($env{'request.course.fn'})) {
@@ -1525,11 +1725,14 @@ sub handler {
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($group);
} else {
- $r->print('You do not have the privileges required to access the shared files space for this group');
+ $r->print('You do not have the privileges required to access the shared files space for this group.');
$earlyout = 1;
}
} else {
@@ -1542,10 +1745,33 @@ sub handler {
$earlyout = 1;
}
if ($earlyout) { return OK; }
+ if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ $can_modify = 1;
+ $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();
$portfolio_root = &get_portfolio_root();
$title = &mt('Portfolio Manager');
+ $can_modify = 1;
+ $can_delete = 1;
+ $can_upload = 1;
+ $can_setacl = 1;
}
&Apache::loncommon::no_cache($r);
@@ -1563,9 +1789,11 @@ sub handler {
}
$r->rflush();
if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
- $r->print(' No file was selected to upload.'.
- 'To upload a file, click Browse...'.
- ', select a file, then click Upload,');
+ $r->print(''.
+ 'No file was selected to upload.'.
+ 'To upload a file, click Browse...'.
+ ', select a file, then click Upload.'.
+ '');
}
if ($env{'form.meta'}) {
&open_form($r,$url);
@@ -1577,31 +1805,71 @@ sub handler {
}
if ($env{'form.uploaddoc.filename'}) {
- &upload($r,$url,$group);
+ if ($can_upload) {
+ &upload($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'upload',$group),
+ }
} elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
- &delete_confirmed($r,$url,$group);
+ if ($can_delete) {
+ &delete_confirmed($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'delete',$group);
+ }
} elsif ($env{'form.action'} eq 'delete') {
- &delete($r,$url,$group);
+ if ($can_delete) {
+ &delete($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'delete',$group);
+ }
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) {
- &delete_dir_confirmed($r,$url,$group);
- } elsif ($env{'form.action'} eq 'deletedir'){
- &delete_dir($r,$url,$group);
+ if ($can_delete) {
+ &delete_dir_confirmed($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'delete',$group);
+ }
+ } elsif ($env{'form.action'} eq 'deletedir') {
+ if ($can_delete) {
+ &delete_dir($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'delete',$group);
+ }
} elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
- &rename_confirmed($r,$url,$group);
+ if ($can_modify) {
+ &rename_confirmed($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'rename',$group);
+ }
} elsif ($env{'form.rename'}) {
$env{'form.selectfile'} = $env{'form.rename'};
$env{'form.action'} = 'rename';
- &rename($r,$url,$group);
+ if ($can_modify) {
+ &rename($r,$url,$group);
+ } else {
+ &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);
+ &display_access($r,$url,$group,$can_setacl);
} elsif ($env{'form.action'} eq 'chgaccess') {
- &update_access($r,$url,$group);
+ if ($can_setacl) {
+ &update_access($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'setacl',$group);
+ }
} elsif ($env{'form.action'} eq 'rolepicker') {
- &role_options_window($r);
+ if ($can_setacl) {
+ &role_options_window($r);
+ } else {
+ &missing_priv($r,$url,'setacl',$group);
+ }
} elsif ($env{'form.createdir'}) {
- &createdir($r,$url,$group);
+ if ($can_upload) {
+ &createdir($r,$url,$group);
+ } else {
+ &missing_priv($r,$url,'upload',$group);
+ }
} elsif ($env{'form.lockinfo'}) {
&lock_info($r,$url,$group);
} else {
@@ -1609,6 +1877,10 @@ 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,$group,$grp_desc));
+ }
my @dir_list=&get_dir_list($portfolio_root,$group);
if ($dir_list[0] eq 'no_such_dir'){
# two main reasons for this:
@@ -1630,11 +1902,14 @@ 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,$group);
- &display_directory($r,$url,$current_path,$is_empty,\@dir_list,$group);
+ &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());
}
return OK;
}
+
1;
__END__
|