--- loncom/interface/portfolio.pm 2006/07/19 14:57:18 1.137 +++ loncom/interface/portfolio.pm 2006/08/16 17:58:54 1.159 @@ -1,7 +1,7 @@ # The LearningOnline Network # portfolio browser # -# $Id: portfolio.pm,v 1.137 2006/07/19 14:57:18 albertel Exp $ +# $Id: portfolio.pm,v 1.159 2006/08/16 17:58:54 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,7 +43,7 @@ use LONCAPA; sub group_args { my $output; if (defined($env{'form.group'})) { - $ouput .= '&group='.$env{'form.group'}; + $output .= '&group='.$env{'form.group'}; if (defined($env{'form.ref'})) { $output .= '&ref='.$env{'form.ref'}; } @@ -54,30 +54,35 @@ sub group_args { sub group_form_data { my $output; if (defined($env{'form.group'})) { - $ouput = ''; + $output = ''; if (exists($env{'form.ref'})) { $output .= ''; } } + return $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) = @_; - if ($continue_select ne 'true') {$continue_select = 'false'}; - my $anchor = ''.$filename.''; + my ($url, $anchor_fields, $inner_text) = @_; + if ($$anchor_fields{'continue'} ne 'true') {$$anchor_fields{'continue'} = 'false'}; + my $anchor = ''.$inner_text.''; return $anchor; } + my $dirptr=16384; sub display_common { my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload)=@_; - my $namespace = &get_namespace($group); - my $port_path = &get_port_path($group); + my $namespace = &get_namespace(); + my $port_path = &get_port_path(); if ($can_upload) { my $groupitem = &group_form_data(); @@ -127,12 +132,26 @@ 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"}).'/'); + my %anchor_fields = ( + 'selectfile' => $port_path, + 'currentpath' => '/', + 'mode' => $env{"form.mode"}, + 'fieldname' => $env{"form.fieldname"}, + 'continue' => $env{"form.continue"} + ); + $r->print(''.&make_anchor($url,\%anchor_fields,$port_path).'/'); 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"}).'/'); + my %anchor_fields = ( + 'selectfile' => $tree[$i], + 'currentpath' => '/', + 'mode' => $env{"form.mode"}, + 'fieldname' => $env{"form.fieldname"}, + 'continue' => $env{"form.continue"} + ); + $r->print(&make_anchor($url,\%anchor_fields,$tree[$i]).'/'); } } $r->print(''); @@ -145,36 +164,62 @@ TABLE } sub display_directory_line { - my ($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class, + my ($r,$select_mode, $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); + $href_location, $url, $current_path, $access_admin_text, $versions)=@_; + + my $fullpath = &prepend_group($current_path.$filename); $r->print(''); - $r->print($line); - $r->print(''); - $r->print(''.$$version_flag{$filename}.''. - $filename.''); + $r->print($line); # contains first two cells of table + my $lock_info; + if ($version_flag) { # versioned can't be versioned, so TRUE when root file + $r->print(''); + $r->print(''.$version_flag.''); + } else { # this is a graded or handed back file + my ($user,$domain) = &get_name_dom(); + my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user); + if (defined($$permissions_hash{$fullpath})) { + foreach my $array_item (@{$$permissions_hash{$fullpath}}) { + if (ref($array_item) eq 'ARRAY') { + if ($$array_item[-1] eq 'handback') { + $lock_info = 'Handback'; + } elsif ($$array_item[-1] eq 'graded') { + $lock_info = 'Graded'; + } + } + } + } + if ($lock_info) { + my %anchor_fields = ('lockinfo' => $fullpath); + $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info); + } + $r->print(''.$lock_info.''); + } + # $r->print(''.$$version_flag{$filename}.''); + $r->print(''.&make_anchor($href_location.$filename,undef,$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.''); + my %anchor_fields = ( + 'access' => $filename, + 'currentpath' => $current_path + ); + $r->print(&make_anchor($url, \%anchor_fields, $access_admin_text).''); } $r->print(''.$/); } sub display_directory { - my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload, + 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 $display_out; my $select_mode; my $checked_files; - my $port_path = &get_port_path($group); - my ($uname,$udom) = &get_name_dom($group); + my $port_path = &get_port_path(); + my ($uname,$udom) = &get_name_dom(); my $access_admin_text = &mt('View Status'); if ($can_setacl) { $access_admin_text = &mt('View/Change Status'); @@ -206,20 +251,19 @@ sub display_directory { if ($select_mode eq 'true') { $r->print('
'); $r->print(''. - ''); + ''); } else { $r->print(''); $r->print('
Select NameSizeLast Modified
Select  NameSizeLast Modified
'. - ''); + ''); } $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); @@ -227,33 +271,43 @@ 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) { - push(@version_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]); - $versioned{$fname.'.'.$extension} .= $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]); } } - 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 $version_flag; my $show_versions; + my $fullpath = &prepend_group($current_path.$filename); if ($env{'form.showversions'} eq $filename) { $show_versions = 'true'; } - if (exists($versioned{$filename})) { + if (exists($versioned{$fullpath})) { + my %anchor_fields = ( + 'selectfile' => $fullpath, + 'continue' => 'false', + 'currentpath' => $current_path, + ); if ($show_versions) { - $version_flag{$filename} = ''.&mt('opened folder').''; + $version_flag = &make_anchor('portfolio',\%anchor_fields, + ''.&mt('opened folder').''); } else { - $version_flag{$filename} = ''.&mt('closed folder').''; + $anchor_fields{'showversions'} = $filename; + $version_flag = &make_anchor('portfolio',\%anchor_fields, + ''.&mt('closed folder').''); } } else { - $version_flag{$filename} = ''; + $version_flag = ' '; } if ($dirptr&$testdir) { my $colspan='colspan="2"'; @@ -262,13 +316,18 @@ sub display_directory { } $r->print(''); $r->print(''); - $r->print(''); + my %anchor_fields = ( + 'selectfile' => $filename.'/', + 'currentpath' => $current_path.$filename.'/', + 'mode' => $env{"form.mode"}, + 'fieldname' => $env{"form.fieldname"}, + 'continue' => $env{"form.continue"} + ); + $r->print(''); $r->print(''); } else { my $css_class = 'LC_browser_file'; my $line; - my $fullpath = $current_path.$filename; - $fullpath = &prepend_group($fullpath,$group); if ($select_mode eq 'true') { $line=''; + my %anchor_fields = ( + 'lockinfo' => $fullpath + ); + $line.=''; $css_class= 'LC_browser_file_locked'; } else { if (!$can_modify) { @@ -289,10 +351,15 @@ sub display_directory { $line .= ''; } if ($can_modify) { - my $cat=''.&mt('Catalog Information').
+                            my $cat='<img class='; - $line .= 'Rename'; - $line .= ''; } @@ -330,27 +397,18 @@ sub display_directory { $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(''.$/); + &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) { - &display_directory_line($r,$select_mode,$fullpath, $css_class, $line, \%access_controls, - $now, \%version_flag, $href_location, $url, $current_path, $access_admin_text); - + 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); + } } } } @@ -400,7 +458,7 @@ sub close_form { 'cancel' => &mt('Cancel'), }; } - $r->print('

') + $r->print('

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

'); $r->print('

@@ -437,22 +495,22 @@ sub done { unless (defined $message) { $message='Done'; } - my $result = '

'.&mt($message).'

'; + 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)); @@ -469,11 +527,11 @@ sub delete { } 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'}. @@ -494,12 +552,12 @@ sub delete_dir { } 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); @@ -523,10 +581,10 @@ sub delete_dir_confirmed { } 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)); @@ -539,10 +597,10 @@ sub rename { } 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."). @@ -570,15 +628,24 @@ sub rename_confirmed { 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.').'
'; + 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 .= '
'; + 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); @@ -619,8 +686,10 @@ sub view_access_settings { } else { $r->print(&mt('No access control settings currently exist for this file.
' )); } - $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; } @@ -753,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) = @@ -827,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'}).'

'); @@ -844,12 +913,13 @@ sub update_access { } &close_form($r,$url); } else { - $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; } @@ -1417,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 . . . @@ -1461,6 +1531,7 @@ ENDSMP } } } + sub upload { my ($r,$url,$group)=@_; my $fname=$env{'form.uploaddoc.filename'}; @@ -1476,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; } @@ -1528,48 +1596,60 @@ sub upload { sub lock_info { my ($r,$url,$group) = @_; - my ($uname,$udom) = &get_name_dom($group); + my ($uname,$udom) = &get_name_dom(); my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, $uname); my $file_name = $env{'form.lockinfo'}; - $file_name = &prepend_group($file_name,$group); + $file_name = &prepend_group($file_name); if (defined($file_name) && defined($$current_permissions{$file_name})) { foreach my $array_item (@{$$current_permissions{$file_name}}) { - if (ref($array_item) eq 'ARRAY') { - my $filetext; - if (defined($group)) { - $filetext = ''.$env{'form.lockinfo'}. - ' (group: '.$group.')'; - } else { - $filetext = ''.$file_name.''; - } - $r->print(&mt('[_1] was submitted in response to problem: ', - $filetext). - ''.&Apache::lonnet::gettitle($$array_item[0]). - '
'); - my %course_description = &Apache::lonnet::coursedescription($$array_item[1]); - $r->print(&mt('In the course: [_1]
', - $course_description{'description'})); - # $r->print('the third is '.$$array_item[2].'
'); - # $r->print("item is $$array_item[0]
and $$array_item[0]"); - } + next if (ref($array_item) ne 'ARRAY'); + + my $filetext; + if (defined($group)) { + $filetext = ''.$env{'form.lockinfo'}. + ' (group: '.$group.')'; + } else { + $filetext = ''.$file_name.''; + } + + my $title =''.&Apache::lonnet::gettitle($$array_item[0]). + '
'; + if ($$array_item[-1] eq 'graded') { + $r->print(&mt('[_1] was submitted in response to problem: [_2]', + $filetext,$title)); + } elsif ($$array_item[-1] eq 'handback') { + $r->print(&mt('[_1] was handed back in response to problem: [_2]', + $filetext,$title)); + } else { + # submission style lock + $r->print(&mt('[_1] was submitted in response to problem: [_2]', + $filetext,$title)); + } + my %course_description = + &Apache::lonnet::coursedescription($$array_item[1]); + if ( $course_description{'description'} ne '') { + $r->print(&mt('In the course: [_1]
', + $course_description{'description'})); + } } } $r->print(&done('Back',$url)); return 'ok'; } + sub createdir { - my ($r,$url,$group)=@_; + my ($r,$url)=@_; 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,$group)); + $r->print(&done(undef,$url)); return; } - my $portfolio_root = &get_portfolio_root($group); - my @dir_list=&get_dir_list($portfolio_root,$group); + my $portfolio_root = &get_portfolio_root(); + my @dir_list=&get_dir_list($portfolio_root); my $found_file = 0; foreach my $line (@dir_list) { my ($filename)=split(/\&/,$line,2); @@ -1581,8 +1661,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($group); - my $port_path = &get_port_path($group); + my ($uname,$udom) = &get_name_dom(); + my $port_path = &get_port_path(); my $result=&Apache::lonnet::mkdiruserfile($uname,$udom, $port_path.$env{'form.currentpath'}.$newdir); if ($result ne 'ok') { @@ -1597,11 +1677,10 @@ sub createdir { } sub get_portfolio_root { - my ($group) = @_; - my ($uname,$udom) = &get_name_dom($group); + my ($uname,$udom) = &get_name_dom(); my $path; - if (defined($group)) { - $path = '/userfiles/groups/'.$group.'/portfolio'; + if (defined($env{'form.group'})) { + $path = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; } else { $path = '/userfiles/portfolio'; } @@ -1626,16 +1705,15 @@ sub get_group_quota { } sub get_dir_list { - my ($portfolio_root,$group) = @_; - my ($uname,$udom) = &get_name_dom($group); + my ($portfolio_root) = @_; + my ($uname,$udom) = &get_name_dom(); return &Apache::lonnet::dirlist($env{'form.currentpath'}, $udom,$uname,$portfolio_root); } sub get_name_dom { - my ($group) = @_; my ($uname,$udom); - if (defined($group)) { + if (defined($env{'form.group'})) { $udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $uname = $env{'course.'.$env{'request.course.id'}.'.num'}; } else { @@ -1646,28 +1724,26 @@ sub get_name_dom { } sub prepend_group { - my ($filename,$group) = @_; - if (defined($group)) { - $filename = $group.$filename; + my ($filename) = @_; + if (defined($env{'form.group'})) { + $filename = $env{'form.group'}.$filename; } return $filename; } sub get_namespace { - my ($group) = @_; my $namespace = 'portfolio'; - if (defined($group)) { - my ($uname,$udom) = &get_name_dom($group); - $namespace .= '_'.$udom.'_'.$uname.'_'.$group; + if (defined($env{'form.group'})) { + my ($uname,$udom) = &get_name_dom(); + $namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'}; } return $namespace; } sub get_port_path { - my ($group) = @_; my $port_path; - if (defined($group)) { - $port_path = "groups/$group/portfolio"; + if (defined($env{'form.group'})) { + $port_path = "groups/$env{'form.group'}/portfolio"; } else { $port_path = 'portfolio'; } @@ -1675,7 +1751,7 @@ sub get_port_path { } sub missing_priv { - my ($r,$url,$priv,$group) = @_; + my ($r,$url,$priv) = @_; my $longtext = { upload => 'upload files', delete => 'delete files', @@ -1693,7 +1769,7 @@ sub missing_priv { $r->print(&mt('

Action disallowed

')); $r->print(&mt('You do not have sufficient privileges to [_1] ', $longtext->{$priv})); - if ($group) { + if (defined($env{'form.group'})) { $r->print(&mt("in the group's file repository.")); $rtnlink .= &group_args() } else { @@ -1717,7 +1793,7 @@ sub coursegrp_portfolio_header { title=>"Course Groups"}); } &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/$cdom/$cnum/$group/smppg?ref=$env{'form.ref'}", + ({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(), @@ -1736,7 +1812,7 @@ sub handler { ['selectfile','currentpath','meta','lockinfo','currentfile','action', 'fieldname','mode','rename','continue','group','access','setnum', 'cnum','cdom','type','setroles','showversions','ref']); - my ($uname,$udom,$portfolio_root,$url,$group,$caller,$title,$grp_desc); + my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc); if ($r->uri =~ m|^(/adm/)([^/]+)|) { $url = $1.$2; $caller = $2; @@ -1754,9 +1830,9 @@ sub handler { 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'}; + $group = $env{'form.group'}; if ($group) { - ($uname,$udom) = &get_name_dom($group); + ($uname,$udom) = &get_name_dom(); my %curr_groups = &Apache::longroup::coursegroups($udom,$uname, $group); if (%curr_groups) { @@ -1765,7 +1841,7 @@ sub handler { $grp_desc = &unescape($grp_content{'description'}); if (($view_permission) || (&Apache::lonnet::allowed('rgf', $env{'request.course.id'}.'/'.$group))) { - $portfolio_root = &get_portfolio_root($group); + $portfolio_root = &get_portfolio_root(); } else { $r->print('You do not have the privileges required to access the shared files space for this group.'); $earlyout = 1; @@ -1809,7 +1885,7 @@ sub handler { $can_setacl = 1; } - my $port_path = &get_port_path($group); + my $port_path = &get_port_path(); &Apache::loncommon::no_cache($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -1844,45 +1920,45 @@ sub handler { if ($can_upload) { &upload($r,$url,$group); } else { - &missing_priv($r,$url,'upload',$group,$refarg), + &missing_priv($r,$url,'upload'); } } elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) { if ($can_delete) { - &delete_confirmed($r,$url,$group); + &delete_confirmed($r,$url); } else { - &missing_priv($r,$url,'delete',$group); + &missing_priv($r,$url,'delete'); } } elsif ($env{'form.action'} eq 'delete') { if ($can_delete) { - &delete($r,$url,$group,$refarg); + &delete($r,$url); } else { - &missing_priv($r,$url,'delete',$group); + &missing_priv($r,$url,'delete'); } } elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) { if ($can_delete) { - &delete_dir_confirmed($r,$url,$group); + &delete_dir_confirmed($r,$url); } else { - &missing_priv($r,$url,'delete',$group); + &missing_priv($r,$url,'delete'); } } elsif ($env{'form.action'} eq 'deletedir') { if ($can_delete) { &delete_dir($r,$url); } else { - &missing_priv($r,$url,'delete',$group); + &missing_priv($r,$url,'delete'); } } elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) { if ($can_modify) { - &rename_confirmed($r,$url,$group); + &rename_confirmed($r,$url); } else { - &missing_priv($r,$url,'rename',$group); + &missing_priv($r,$url,'rename'); } } elsif ($env{'form.rename'}) { $env{'form.selectfile'} = $env{'form.rename'}; $env{'form.action'} = 'rename'; if ($can_modify) { - &rename($r,$url,$group); + &rename($r,$url); } else { - &missing_priv($r,$url,'rename',$group); + &missing_priv($r,$url,'rename'); } } elsif ($env{'form.access'}) { $env{'form.selectfile'} = $env{'form.access'}; @@ -1892,19 +1968,19 @@ sub handler { if ($can_setacl) { &update_access($r,$url,$group,$port_path); } else { - &missing_priv($r,$url,'setacl',$group); + &missing_priv($r,$url,'setacl'); } } elsif ($env{'form.action'} eq 'rolepicker') { if ($can_setacl) { &role_options_window($r); } else { - &missing_priv($r,$url,'setacl',$group); + &missing_priv($r,$url,'setacl'); } } elsif ($env{'form.createdir'}) { if ($can_upload) { - &createdir($r,$url,$group); + &createdir($r,$url); } else { - &missing_priv($r,$url,'upload',$group); + &missing_priv($r,$url,'upload'); } } elsif ($env{'form.lockinfo'}) { &lock_info($r,$url,$group); @@ -1917,14 +1993,14 @@ sub handler { &Apache::lonhtmlcommon::clear_breadcrumbs(); $r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc)); } - my @dir_list=&get_dir_list($portfolio_root,$group); + my @dir_list=&get_dir_list($portfolio_root); 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($group)); + &get_port_path()); } else { # some directory that snuck in get rid of the directory # from the recent pulldown, just in case @@ -1940,7 +2016,7 @@ sub handler { my $is_empty=(@dir_list == 2); &display_common($r,$url,$current_path,$is_empty,\@dir_list, $can_upload); - &display_directory($r,$url,$current_path,$is_empty,\@dir_list, + &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()); }
Actions NameSizeLast ModifiedCurrent Access Status
Actions  NameSizeLast ModifiedCurrent Access Status
'.&mt('closed folder').'Go to ...'.$version_flag{$filename}.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).'/'.$version_flag.''.&make_anchor($url,\%anchor_fields,$filename.'/').'
Locked'.&make_anchor($url,\%anchor_fields,'Locked').''.$version_flag{$filename}.''.$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 .= '
'.$version_flag{$filename}.''. -# $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''. -# &mt($curr_access).'   '); -# $r->print(''.$access_admin_text.'