--- loncom/interface/portfolio.pm 2006/03/15 19:41:26 1.95 +++ loncom/interface/portfolio.pm 2006/08/11 23:45:18 1.153 @@ -1,3 +1,8 @@ +# The LearningOnline Network +# portfolio browser +# +# $Id: portfolio.pm,v 1.153 2006/08/11 23:45:18 banghart Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -30,112 +35,191 @@ use Apache::lontexconvert; 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) = @_; - 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,$group)=@_; - my $groupitem; - my $namespace = &get_namespace($group); - my $port_path = &get_port_path($group); - if (defined($group)) { - $groupitem = ''; - } - my $iconpath= $r->dir_config('lonIconsURL') . "/"; - my %text=&Apache::lonlocal::texthash('upload' => 'Upload', + 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 = &group_form_data(); + + my $iconpath= $r->dir_config('lonIconsURL') . "/"; + my %text=&Apache::lonlocal::texthash( + 'upload' => 'Upload', 'upload_label' => 'Upload file to current directory:', 'createdir' => 'Create Subdirectory', 'createdir_label' => 'Create subdirectory in current directory:'); - $r->print(<<"TABLE"); -
Select | Name | Size | Last Modified |
---|
Select | Name | Size | Last Modified |
---|
Actions | Name | Size | Last Modified |
---|
Actions | Name | Size | Last Modified | Current Access Status | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'); - } else { - $r->print(' | |||||||||||||||
'); + undef($colspan); } + $r->print(' | |||||||||||||||
'); $r->print(' | Go to ... | '); - $r->print(''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).' | '); + my %anchor_fields = ( + 'selectfile' => $filename.'/', + 'currentpath' => $current_path.$filename.'/', + 'mode' => $env{"form.mode"}, + 'fieldname' => $env{"form.fieldname"}, + 'continue' => $env{"form.continue"} + ); + $r->print(''.$version_flag{$filename}.' | '.&make_anchor($url,\%anchor_fields,$filename.'/').' | '); $r->print('|||||||||||
print("CHECKED"); + my $css_class = 'LC_browser_file'; + my $line; + my $fullpath = $current_path.$filename; + $fullpath = &prepend_group($fullpath); + if ($select_mode eq 'true') { + $line=' | print('> | '); + $line.=' />'; } else { - if (exists $locked_files{$current_path.$filename}){ - $r->print('Locked | '); + if (exists $locked_files{$fullpath}) { + my %anchor_fields = ( + 'lockinfo' => $current_path.$filename + ); + $line.=''.&make_anchor($url,\%anchor_fields,'Locked').' | '; + $css_class= 'LC_browser_file_locked'; } else { - my $cat=''; - $r->print('- Rename | -'.$cat.' - | '); + if (!$can_modify) { + $line .= ''; + } else { + $line .= ' | '; + } + if ($can_delete) { + $line .= ''; + } + if ($can_modify) { + my $cat=''; + my %anchor_fields = ( + 'rename' => $filename, + currentpath => $current_path + ); + $line .= &make_anchor($url,\%anchor_fields,'Rename'); + $line .= ' | '.&make_anchor($href_edit_location.$filename.'.meta',undef,$cat); + # ''.$cat.''; + } + $line .= ' | '; } } - $r->print(''); - $r->print(' | '. - $filename.' | '); - $r->print(''.$size.' | '); - $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | '); - $r->print(''; + if (($v_fname eq $fname)&&($v_extension eq $extension)) { + &display_directory_line($r,$select_mode,$fullpath, $v_filename, $mtime, $size, + $css_class, $line, \%access_controls, $curr_access, $now, + \%version_flag, $href_location, $url, $current_path, $access_admin_text, 1); + } + } + } } } } if ($select_mode eq 'true') { $r->print(' |
'); - if (defined($group)) { - $r->print("\n".''); - } - $r->print('
'); + $r->print(&group_form_data().'
'); - if (defined($group)) { - $r->print("\n".''); - } - $r->print("\n".' + $env{'form.currentpath'}.'" />'. + &group_form_data()); + $r->print("\n".'
'.&mt('Delete').' '.&display_file(undef,\@files).'?
'); - &close_form($r,$url,$group); + &close_form($r,$url); } else { $r->print("No file was checked to delete.'.&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); if ($result ne 'ok') { - $r->print(' An error occured (dir) ('.$result. - ') while trying to delete '.$directory_name.''.&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(''. + $r->print(''. &mt("Error: no valid filename was provided to rename to."). - ''.&mt('Roles').' | '. + &mt('Access').' | '. + &mt('Sections').' | '); + if ($scope eq 'course') { + $r->print(''.&mt('Groups').' | '); + } else { + $r->print(''.&mt('Teams').' | '); + } + $r->print('
---|---|---|---|---|
'); + if ($item eq 'role') { + my $ucscope = $scope; + $ucscope =~ s/^(\w)/uc($1)/e; + 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(''.&mt('Public access:').' '.$publictext.''); + $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table_header_row()); + $r->print(' | '.&mt('Action').' | '.&mt('Dates available').' | '); + $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').' | '. + &dateboxes($publicnum,$start{$public},$end{$public}).' | '); + } else { + $r->print(''.&actionbox('new','0','public').' | '. + &dateboxes('0',$now,$then).' | '); + } + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table()); + $r->print('');
+ $r->print(''.&mt('Passphrase-protected access:').' '.$guesttext.''); + $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table_header_row()); + $r->print(' | '.&mt('Action').' | '.&mt('Dates available'). + ' | '. &mt('Passphrase').' | '); + $r->print(&Apache::loncommon::end_data_table_header_row()); + $r->print(&Apache::loncommon::start_data_table_row()); + my $passwd; + if ($guest) { + $passwd = $$access_controls{$guest}{'password'}; + $r->print(''.&actionbox('old',$guestnum,'guest').' | '. + &dateboxes($guestnum,$start{$guest},$end{$guest}).' | '); + } else { + $r->print(''.&actionbox('new','1','guest').' | '. + &dateboxes('1',$now,$then).' | '); + } + $r->print(''); + $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(' | |||||||||||||||
'); + } 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(' |
'.&mt('Action').' | '.&mt('Roles').' | '. + &mt('Access').' | '.&mt('Sections').' | '. + &mt($crsgrptext).' |
---|---|---|---|---|
'.&mt('Roles').' | '.&mt('[_1] status',$type).' | '.&mt('Sections').' | '.&mt($grouptitle).' |
---|---|---|---|