--- loncom/interface/portfolio.pm 2006/06/29 18:02:58 1.121.2.4 +++ loncom/interface/portfolio.pm 2006/07/19 21:59:10 1.121.2.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # portfolio browser # -# $Id: portfolio.pm,v 1.121.2.4 2006/06/29 18:02:58 albertel Exp $ +# $Id: portfolio.pm,v 1.121.2.8 2006/07/19 21:59:10 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,32 +36,53 @@ 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,$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 $namespace = &get_namespace($group); - my $port_path = &get_port_path($group); + my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload)=@_; + my $namespace = &get_namespace(); + my $port_path = &get_port_path(); 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', @@ -108,43 +129,36 @@ 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 { 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($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'); } - if ((defined($group)) && (defined($env{'request.course.id'}))) { - $groupitem = ''; - $groupecho = '&group='.$group; - } my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, $uname); @@ -158,7 +172,8 @@ sub display_directory { $select_mode = 'true'; } if ($is_empty && ($current_path ne '/') && $can_delete) { - $display_out = '
'.$groupitem. + $display_out = ''. + &group_form_data(). ''. ''. ''. @@ -177,9 +192,8 @@ 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; @@ -211,7 +225,7 @@ sub display_directory { } $r->print(''); $r->print(''); - $r->print(''); + $r->print(''); $r->print(''); } else { my $css_class = 'LC_browser_file'; @@ -223,7 +237,7 @@ sub display_directory { $version_flag = ""; } my $fullpath = $current_path.$filename; - $fullpath = &prepend_group($fullpath,$group); + $fullpath = &prepend_group($fullpath); if ($select_mode eq 'true') { $line=''; + $line.=''; $css_class= 'LC_browser_file_locked'; } else { if (!$can_modify) { @@ -246,7 +260,7 @@ sub display_directory { if ($can_modify) { my $cat=''.&mt('Catalog Information').
                             ''; - $line .= 'Rename'; + $line .= 'Rename'; $line .= ''; @@ -296,18 +310,18 @@ sub display_directory { $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'},$group).''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'}).'
LockedLocked'.$cat.''; } $line .= ''. &mt($curr_access).'   '); $r->print(''.$access_admin_text.''); + '&currentpath='.$current_path.&group_args(). + '">'.$access_admin_text.'
- - - + + +
@@ -341,7 +355,7 @@ 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'), @@ -349,19 +363,12 @@ sub close_form { }; } $r->print('

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

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

'); $r->print('

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

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

'.&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,$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)); } } } 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'}. @@ -440,23 +445,23 @@ 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 { - 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); @@ -476,35 +481,35 @@ sub delete_dir_confirmed { } $env{'form.currentpath'} = $directory_name; } - $r->print(&done(undef,$url,$group)); + $r->print(&done(undef,$url)); } 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,$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); } } 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."). '
'); - $r->print(&done(undef,$url,$group)); + $r->print(&done(undef,$url)); return; } my $result= @@ -522,19 +527,21 @@ 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 ($uname,$udom) = &get_name_dom($group); + my ($r,$url,$group,$can_setacl,$port_path) = @_; + 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]',$env{'form.currentpath'}.$env{'form.access'}).'

'; + 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.'). '