--- loncom/interface/portfolio.pm 2006/07/19 21:59:10 1.121.2.8 +++ loncom/interface/portfolio.pm 2006/06/27 15:37:17 1.122 @@ -1,8 +1,3 @@ -# The LearningOnline Network -# portfolio browser -# -# $Id: portfolio.pm,v 1.121.2.8 2006/07/19 21:59:10 albertel Exp $ -# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -36,53 +31,32 @@ 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'})) { - $output .= '&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'})) { - $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) = @_; + $continue_select,$group) = @_; 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,$can_upload)=@_; - my $namespace = &get_namespace(); - my $port_path = &get_port_path(); + my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload)=@_; + my $namespace = &get_namespace($group); + my $port_path = &get_port_path($group); if ($can_upload) { - my $groupitem = &group_form_data(); - + my $groupitem; + if (defined($group)) { + $groupitem = ''; + } my $iconpath= $r->dir_config('lonIconsURL') . "/"; my %text=&Apache::lonlocal::texthash( 'upload' => 'Upload', @@ -129,36 +103,43 @@ 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"}).'/'); + $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++){ $newCurrentPath .= $tree[$i].'/'; - $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"}).'/'); + $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/'); } } $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 { 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; my $select_mode; my $checked_files; - my $port_path = &get_port_path(); - my ($uname,$udom) = &get_name_dom(); + my $port_path = &get_port_path($group); + my ($uname,$udom) = &get_name_dom($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); @@ -172,8 +153,7 @@ sub display_directory { $select_mode = 'true'; } if ($is_empty && ($current_path ne '/') && $can_delete) { - $display_out = '
'. - &group_form_data(). + $display_out = ''.$groupitem. ''. ''. ''. @@ -192,8 +172,9 @@ sub display_directory { $r->print(''. ''); } - $r->print("\n".&group_form_data()."\n"); - + if (defined($group)) { + $r->print("\n".$groupitem."\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; @@ -225,7 +206,7 @@ sub display_directory { } $r->print(''); $r->print(''); - $r->print(''); + $r->print(''); $r->print(''); } else { my $css_class = 'LC_browser_file'; @@ -237,8 +218,8 @@ sub display_directory { $version_flag = ""; } my $fullpath = $current_path.$filename; - $fullpath = &prepend_group($fullpath); - if ($select_mode eq 'true') { + $fullpath = &prepend_group($fullpath,$group); + if ($select_mode eq 'true'){ $line=''; + $line.=''; $css_class= 'LC_browser_file_locked'; } else { if (!$can_modify) { @@ -260,68 +241,64 @@ sub display_directory { if ($can_modify) { my $cat=''.&mt('Catalog Information').
                             ''; - $line .= 'Rename'; + $line .= 'Rename'; $line .= ''; } + $r->print(''); + $r->print($line); } - $r->print(''); - $r->print($line); - 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); - } - } - $r->print(''); - $r->print(''); - $r->print(''); - $r->print(''); - if ($select_mode ne 'true') { - $r->print(''); - } - $r->print(''.$/); + 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(''); } } } 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'}).''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).'
LockedLocked'.$cat.''; } $line .= '
'. - $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''. - &mt($curr_access).'   '); - $r->print(''.$access_admin_text.'
'. + $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''. + &mt($curr_access).'   '); + $r->print(''.$access_admin_text.''); + $r->print('
- - - + + +
@@ -355,7 +332,7 @@ sub open_form { } sub close_form { - my ($r,$url,$button_text)=@_; + my ($r,$url,$group,$button_text)=@_; if (!defined($button_text)) { $button_text = { 'continue' => &mt('Continue'), @@ -363,12 +340,19 @@ sub close_form { }; } $r->print('

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

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

'); $r->print('

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

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

'.&mt($message).'

'; 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('Delete').' '.&display_file(undef,\@files).'?

'); - &close_form($r,$url); + &close_form($r,$url,$group); } else { $r->print("No file was checked to delete.
"); - $r->print(&done(undef,$url)); + $r->print(&done(undef,$url,$group)); } } } sub delete_confirmed { - my ($r,$url)=@_; + my ($r,$url,$group)=@_; my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); my $result; - 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); foreach my $delete_file (@files) { $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. $env{'form.currentpath'}. @@ -445,23 +431,23 @@ sub delete_confirmed { ') while trying to delete '.&display_file(undef, $delete_file).'

'); } } - $r->print(&done(undef,$url)); + $r->print(&done(undef,$url,$group)); } sub delete_dir { - my ($r,$url)=@_; + my ($r,$url,$group)=@_; &open_form($r,$url); $r->print('

'.&mt('Delete').' '.&display_file().'?

'); - &close_form($r,$url); + &close_form($r,$url,$group); } sub delete_dir_confirmed { - my ($r,$url)=@_; + my ($r,$url,$group)=@_; my $directory_name = $env{'form.currentpath'}; $directory_name =~ s|/$||; # remove any trailing slash - my ($uname,$udom) = &get_name_dom(); - my $namespace = &get_namespace(); - my $port_path = &get_port_path(); + my ($uname,$udom) = &get_name_dom($group); + my $namespace = &get_namespace($group); + my $port_path = &get_port_path($group); my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. $directory_name); @@ -481,35 +467,35 @@ sub delete_dir_confirmed { } $env{'form.currentpath'} = $directory_name; } - $r->print(&done(undef,$url)); + $r->print(&done(undef,$url,$group)); } sub rename { - my ($r,$url)=@_; + my ($r,$url,$group)=@_; my $file_name = $env{'form.currentpath'}.$env{'form.rename'}; - my ($uname,$udom) = &get_name_dom(); - $file_name = &prepend_group($file_name); + my ($uname,$udom) = &get_name_dom($group); + $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)); + $r->print(&done(undef,$url,$group)); } else { &open_form($r,$url); $r->print('

'.&mt('Rename').' '.&display_file().' to ?

'); - &close_form($r,$url); + &close_form($r,$url,$group); } } sub rename_confirmed { - my ($r,$url)=@_; + my ($r,$url,$group)=@_; my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); - 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); if ($filenewname eq '') { $r->print(''. &mt("Error: no valid filename was provided to rename to."). '
'); - $r->print(&done(undef,$url)); + $r->print(&done(undef,$url,$group)); return; } my $result= @@ -527,21 +513,19 @@ sub rename_confirmed { ''.&display_file('',$env{'form.filenewname'}).'', ''.&display_file('',$filenewname).'')); } - $r->print(&done(undef,$url)); + $r->print(&done(undef,$url,$group)); } sub display_access { - my ($r,$url,$group,$can_setacl,$port_path) = @_; - my ($uname,$udom) = &get_name_dom(); + my ($r,$url,$group,$can_setacl) = @_; + my ($uname,$udom) = &get_name_dom($group); my $file_name = $env{'form.currentpath'}.$env{'form.access'}; - $file_name = &prepend_group($file_name); + $file_name = &prepend_group($file_name,$group); 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 $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.'). '