--- loncom/interface/portfolio.pm 2006/06/27 15:38:08 1.121.2.1 +++ loncom/interface/portfolio.pm 2006/07/19 14:57:18 1.137 @@ -1,3 +1,8 @@ +# The LearningOnline Network +# portfolio browser +# +# $Id: portfolio.pm,v 1.137 2006/07/19 14:57:18 albertel Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -31,32 +36,51 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; +use Apache::lonhtmlcommon; use HTML::Entities; use LONCAPA; +sub group_args { + my $output; + if (defined($env{'form.group'})) { + $ouput .= '&group='.$env{'form.group'}; + if (defined($env{'form.ref'})) { + $output .= '&ref='.$env{'form.ref'}; + } + } + return $output; +} + +sub group_form_data { + my $output; + if (defined($env{'form.group'})) { + $ouput = ''; + if (exists($env{'form.ref'})) { + $output .= ''; + } + } +} + # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { my ($url, $filename, $current_path, $current_mode, $field_name, - $continue_select,$group) = @_; + $continue_select) = @_; if ($continue_select ne 'true') {$continue_select = 'false'}; my $anchor = ''.$filename.''; return $anchor; } my $dirptr=16384; sub display_common { - my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload)=@_; + my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload)=@_; my $namespace = &get_namespace($group); my $port_path = &get_port_path($group); if ($can_upload) { - my $groupitem; - if (defined($group)) { - $groupitem = ''; - } + my $groupitem = &group_form_data(); + my $iconpath= $r->dir_config('lonIconsURL') . "/"; my %text=&Apache::lonlocal::texthash( 'upload' => 'Upload', @@ -103,30 +127,49 @@ sub display_common { 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"}).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @tree; $i++){ $newCurrentPath .= $tree[$i].'/'; - $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/'); + $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"}).'/'); } } $r->print(''); &Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path); - $r->print('
'. &Apache::lonhtmlcommon::select_recent($namespace,'currentpath', 'this.form.submit();')); $r->print("
"); } + +sub display_directory_line { + my ($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)=@_; + # my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); + $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(''.$/); +} + sub display_directory { - my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload, + my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload, $can_modify,$can_delete,$can_setacl)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; - my ($groupitem,$groupecho); my $display_out; my $select_mode; my $checked_files; @@ -136,10 +179,6 @@ sub display_directory { 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); @@ -153,7 +192,8 @@ sub display_directory { $select_mode = 'true'; } if ($is_empty && ($current_path ne '/') && $can_delete) { - $display_out = '
'.$groupitem. + $display_out = ''. + &group_form_data(). ''. ''. ''. @@ -172,12 +212,12 @@ sub display_directory { $r->print(''. ''); } - if (defined($group)) { - $r->print("\n".$groupitem."\n"); - } + $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 { @@ -191,14 +231,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} = ''.&mt('opened folder').''; + } else { + $version_flag{$filename} = ''.&mt('closed folder').''; + } + } else { + $version_flag{$filename} = ''; + } if ($dirptr&$testdir) { my $colspan='colspan="2"'; if ($select_mode eq 'true'){ @@ -206,20 +262,14 @@ sub display_directory { } $r->print(''); $r->print(''); - $r->print(''); + $r->print(''); $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; + my $fullpath = $current_path.$filename; $fullpath = &prepend_group($fullpath,$group); - if ($select_mode eq 'true'){ + if ($select_mode eq 'true') { $line=''; + $line.=''; $css_class= 'LC_browser_file_locked'; } else { if (!$can_modify) { @@ -241,64 +291,75 @@ sub display_directory { if ($can_modify) { my $cat=''.&mt('Catalog Information').
                             ''; - $line .= 'Rename'; - $line .= ''; } - $r->print(''); - $r->print($line); - } - my $curr_access; - my $pub_access = 0; - my $guest_access = 0; - my $cond_access = 0; - foreach my $key (sort(keys(%{$access_controls{$fullpath}}))) { - my ($num,$scope,$end,$start) = &unpack_acc_key($key); - if (($now > $start) && (!$end || $end > $now)) { - if ($scope eq 'public') { - $pub_access = 1; - } elsif ($scope eq 'guest') { - $guest_access = 1; - } else { - $cond_access = 1; - } - } - } - if (!$pub_access && !$guest_access && !$cond_access) { - $curr_access = &mt('Private'); - } else { - my @allaccesses; - if ($pub_access) { - push(@allaccesses,&mt('Public')); - } - if ($guest_access) { - push(@allaccesses,&mt('Passphrase-protected')); - } - if ($cond_access) { - push(@allaccesses,&mt('Conditional')); - } - $curr_access = join('+ ',@allaccesses); } - $r->print(''); - $r->print(''); - $r->print(''); - $r->print(''); - $r->print(''); + my $curr_access; + if ($select_mode ne 'true') { + my $pub_access = 0; + my $guest_access = 0; + my $cond_access = 0; + foreach my $key (sort(keys(%{$access_controls{$fullpath}}))) { + my ($num,$scope,$end,$start) = &unpack_acc_key($key); + if (($now > $start) && (!$end || $end > $now)) { + if ($scope eq 'public') { + $pub_access = 1; + } elsif ($scope eq 'guest') { + $guest_access = 1; + } else { + $cond_access = 1; + } + } + } + if (!$pub_access && !$guest_access && !$cond_access) { + $curr_access = &mt('Private'); + } else { + my @allaccesses; + if ($pub_access) { + push(@allaccesses,&mt('Public')); + } + if ($guest_access) { + push(@allaccesses,&mt('Passphrase-protected')); + } + if ($cond_access) { + push(@allaccesses,&mt('Conditional')); + } + $curr_access = join('+ ',@allaccesses); + } + } + &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); +# $r->print(''); +# $r->print($line); +# $r->print(''); +# $r->print(''); +# $r->print(''); +# $r->print(''); +# if ($select_mode ne 'true') { +# $r->print(''); +# } +# $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, $access_admin_text); + + } } } } if ($select_mode eq 'true') { $r->print('
Actions NameSizeLast ModifiedCurrent Access Status
'.&mt('closed folder').'Go to ...'.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).''.$version_flag{$filename}.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).'/
LockedLocked'.$cat.''; + $line .= 'Rename'; + $line .= ''.$version_flag{$filename}.''.$cat.''; } $line .= '
'. - $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''. - &mt($curr_access).'   '); - $r->print(''.$access_admin_text.''); - $r->print('
'.$version_flag{$filename}.''. +# $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''. +# &mt($curr_access).'   '); +# $r->print(''.$access_admin_text.'
- - - + + +
@@ -332,27 +393,20 @@ 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'), 'cancel' => &mt('Cancel'), }; } - $r->print('

'); - if (defined($group)) { - $r->print("\n".''); - } - $r->print('

'); + $r->print('

') + $r->print(&group_form_data().'

'); $r->print('

'); - if (defined($group)) { - $r->print("\n".''); - } + $env{'form.currentpath'}.'" />'. + &group_form_data()); $r->print("\n".'

'); } @@ -379,17 +433,15 @@ sub display_file { } sub done { - my ($message,$url,$group)=@_; + my ($message,$url)=@_; unless (defined $message) { $message='Done'; } my $result = '

'.&mt($message).'

'; return $result; } @@ -403,15 +455,15 @@ sub delete { 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,$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)); } } } @@ -431,14 +483,14 @@ 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 { @@ -467,7 +519,7 @@ sub delete_dir_confirmed { } $env{'form.currentpath'} = $directory_name; } - $r->print(&done(undef,$url,$group)); + $r->print(&done(undef,$url)); } sub rename { @@ -477,12 +529,12 @@ sub rename { $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,$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); } } @@ -495,7 +547,7 @@ sub rename_confirmed { $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= @@ -513,11 +565,11 @@ 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 ($r,$url,$group,$can_setacl,$port_path) = @_; my ($uname,$udom) = &get_name_dom($group); my $file_name = $env{'form.currentpath'}.$env{'form.access'}; $file_name = &prepend_group($file_name,$group); @@ -525,21 +577,8 @@ sub display_access { $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.'). - '
'; + 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.').'
'; if ($can_setacl) { &open_form($r,$url); $r->print($header.$info); @@ -548,19 +587,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}))) { @@ -581,12 +619,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; } @@ -694,7 +728,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 = ( @@ -720,7 +754,7 @@ 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"); + $port_path.$file_name).''."\n"); $file_name = &prepend_group($file_name,$group); my ($uname,$udom) = &get_name_dom($group); my ($errors,$outcome,$deloutcome,$new_values,$translation); @@ -808,15 +842,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').''); + &mt('Display all access settings for this file').''. + '     '. + ''.&mt('Return to directory listing').''); } return; } @@ -986,25 +1019,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(''); } @@ -1413,11 +1445,7 @@ ENDSMP fileList = fileList + document.forms.checkselect.currentpath.value + document.forms.checkselect[i].value + "," ; } } - opener.document.forms.lonhomework. -ENDSMP - $javascript .= $env{'form.fieldname'}; - $javascript .= (< @@ -1438,6 +1466,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); @@ -1465,17 +1501,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,$group)); + $r->print(&done('Back',$url)); } 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,$group)); + $r->print(&done('Back',$url)); } 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,$group)); + $r->print(&done('Back',$url)); } } else { my $result=&Apache::lonnet::userfileupload('uploaddoc','', @@ -1483,12 +1519,13 @@ sub upload { if ($result !~ m|^/uploaded/|) { $r->print(''.'An errror occured ('.$result. ') while trying to upload '.&display_file().'
'); - $r->print(&done('Back',$url,$group)); + $r->print(&done('Back',$url)); } else { - $r->print(&done(undef,$url,$group)); + $r->print(&done(undef,$url)); } } } + sub lock_info { my ($r,$url,$group) = @_; my ($uname,$udom) = &get_name_dom($group); @@ -1518,7 +1555,7 @@ sub lock_info { } } } - $r->print(&done('Back',$url,$group)); + $r->print(&done('Back',$url)); return 'ok'; } sub createdir { @@ -1556,13 +1593,13 @@ 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,$group)); + $r->print(&done(undef,$url)); } sub get_portfolio_root { my ($group) = @_; - my ($portfolio_root,$udom,$uname,$path); - ($uname,$udom) = &get_name_dom($group); + my ($uname,$udom) = &get_name_dom($group); + my $path; if (defined($group)) { $path = '/userfiles/groups/'.$group.'/portfolio'; } else { @@ -1571,6 +1608,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); @@ -1641,7 +1695,7 @@ sub missing_priv { $longtext->{$priv})); if ($group) { $r->print(&mt("in the group's file repository.")); - $rtnlink .= '&group='.$group; + $rtnlink .= &group_args() } else { $r->print(&mt('in this portfolio.')); } @@ -1651,14 +1705,38 @@ 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/$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; &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','ref']); + my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc); if ($r->uri =~ m|^(/adm/)([^/]+)|) { $url = $1.$2; $caller = $2; @@ -1673,15 +1751,18 @@ sub handler { return HTTP_NOT_ACCEPTABLE; } my $earlyout = 0; - my $view_permission = &Apache::lonnet::allowed('vcg', - $env{'request.course.id'}); - $group = $env{'form.group'}; - $group =~ s/\W//g; + 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; + my $group = $env{'form.group'}; if ($group) { ($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($group); @@ -1699,17 +1780,24 @@ sub handler { $earlyout = 1; } if ($earlyout) { return OK; } - 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)) { + if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { $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(); @@ -1721,6 +1809,7 @@ sub handler { $can_setacl = 1; } + my $port_path = &get_port_path($group); &Apache::loncommon::no_cache($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -1746,7 +1835,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,$group); + &close_form($r,$url); } if ($env{'form.store'}) { } @@ -1755,7 +1844,7 @@ sub handler { if ($can_upload) { &upload($r,$url,$group); } else { - &missing_priv($r,$url,'upload',$group), + &missing_priv($r,$url,'upload',$group,$refarg), } } elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) { if ($can_delete) { @@ -1765,7 +1854,7 @@ sub handler { } } elsif ($env{'form.action'} eq 'delete') { if ($can_delete) { - &delete($r,$url,$group); + &delete($r,$url,$group,$refarg); } else { &missing_priv($r,$url,'delete',$group); } @@ -1777,7 +1866,7 @@ sub handler { } } elsif ($env{'form.action'} eq 'deletedir') { if ($can_delete) { - &delete_dir($r,$url,$group); + &delete_dir($r,$url); } else { &missing_priv($r,$url,'delete',$group); } @@ -1798,10 +1887,10 @@ sub handler { } elsif ($env{'form.access'}) { $env{'form.selectfile'} = $env{'form.access'}; $env{'form.action'} = 'chgaccess'; - &display_access($r,$url,$group,$can_setacl); + &display_access($r,$url,$group,$can_setacl,$port_path); } elsif ($env{'form.action'} eq 'chgaccess') { if ($can_setacl) { - &update_access($r,$url,$group); + &update_access($r,$url,$group,$port_path); } else { &missing_priv($r,$url,'setacl',$group); } @@ -1824,6 +1913,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,$grp_desc)); + } my @dir_list=&get_dir_list($portfolio_root,$group); if ($dir_list[0] eq 'no_such_dir'){ # two main reasons for this: @@ -1845,9 +1938,9 @@ 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, - $can_upload); - &display_directory($r,$url,$current_path,$is_empty,\@dir_list,$group, + &display_common($r,$url,$current_path,$is_empty,\@dir_list, + $can_upload); + &display_directory($r,$url,$current_path,$is_empty,\@dir_list, $can_upload,$can_modify,$can_delete,$can_setacl); $r->print(&Apache::loncommon::end_page()); }