--- loncom/interface/portfolio.pm 2006/06/22 13:27:13 1.108 +++ loncom/interface/portfolio.pm 2008/04/17 14:46:18 1.192 @@ -1,3 +1,8 @@ +# The LearningOnline Network +# portfolio browser +# +# $Id: portfolio.pm,v 1.192 2008/04/17 14:46:18 raeburn Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -31,118 +36,221 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; -use lib '/home/httpd/lib/perl'; +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 | Current Access Status |
---|
'.&mt('Actions'). &Apache::loncommon::help_open_topic('Portfolio FileAction').' | ' + .'' + .' | '.&mt('Name').&Apache::loncommon::help_open_topic('Portfolio OpenFile').' | ' + .''.&mt('Size').' | ' + .''.&mt('Last Modified').' | ' + .''.&mt('Current Access Status').&Apache::loncommon::help_open_topic('Portfolio ShareFile').' | ' + .'|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'); - } else { - $r->print(' | ||||||||||||||||
'); + undef($colspan); } - $r->print(' | Go to ... | '); - $r->print(''.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).' | '); + $r->print('||||||||||||||
'); + $r->print(' | '.&mt('Go to ...').' | '); + 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.' | '.&make_anchor($url,\%anchor_fields,$filename.'/').' | '); $r->print('|||||||||||||
print("CHECKED"); + my $css_class = 'LC_browser_file'; + my $line; + if ($select_mode eq 'true') { + $line=' | print('> | '); + $line.=' />'; } else { if (exists $locked_files{$fullpath}) { - $r->print('Locked | '); + my %anchor_fields = ( + 'lockinfo' => $fullpath + ); + $line.=''.&make_anchor($url,\%anchor_fields,&mt('Locked')).' | '; + $css_class= 'LC_browser_file_locked'; } else { - my $cat=''; - $r->print('- Rename | -'.$cat.' - | '); - } - } - 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; + if (!$can_modify) { + $line .= ''; } else { - $cond_access = 1; + $line .= ' | '; } + if ($can_delete) { + $line .= ''; + } + if ($can_modify) { + my $cat=''; + my %anchor_fields = ( + 'rename' => $filename, + currentpath => $current_path + ); + $line .= &make_anchor($url,\%anchor_fields,&mt('Rename')); + $line .= ' | '.&make_anchor($href_edit_location.$filename.'.meta',\%anchor_fields,$cat); + # ''.$cat.''; + } + $line .= ' | '; } } - 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('Password-protected')); - } - if ($cond_access) { - push(@allaccesses,&mt('Conditional')); - } - $curr_access = join('+ ',@allaccesses); - } - $r->print(''); - $r->print(' | '. - $filename.' | '); - $r->print(''.$size.' | '); - $r->print(''.&Apache::lonlocal::locallocaltime($mtime).' | '); - $r->print(''; + &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); + } + } } } } if ($select_mode eq 'true') { $r->print(' |
'); - if (defined($group)) { - $r->print("\n".''); - } - $r->print('
'); - $r->print(''); - if (defined($group)) { - $r->print("\n".''); - } + $env{'form.currentpath'}.'" />'. + &group_form_data()); $r->print("\n".'
'.&mt('Delete').' '.&display_file(undef,\@files).'?
'); - &close_form($r,$url,$group); + $r->print(''.&mt('Delete [_1]?',&display_file(undef,\@files)).'
'); + &close_form($r,$url); } else { $r->print("No file was checked to delete.'.&mt('Delete').' '.&display_file().'?
'); - &close_form($r,$url,$group); + $r->print(''.&mt('Delete [_1]?',&display_file()).'
'); + &close_form($r,$url); } sub delete_dir_confirmed { @@ -413,43 +619,42 @@ sub delete_dir_confirmed { 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 $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); + $r->print(''.&mt('Rename [_1] to [_2]?', &display_file() + , '').'
'); + &close_form($r,$url); } } @@ -457,52 +662,276 @@ sub rename_confirmed { my ($r,$url,$group)=@_; my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); my ($uname,$udom) = &get_name_dom($group); - my $port_path = &get_port_path($group); + 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').' | '); + $r->print(''.&mt('Groups').' | '); + $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('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)/; - 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(&Apache::loncommon::end_data_table_row()); - $r->print(&Apache::loncommon::end_data_table()); - } elsif ($scope eq 'domains') { - $r->print(&mt('Domains: ').join(',',@{$content{'dom'}})); - } elsif ($scope eq 'users') { - my $curr_user_list = &sort_users($content{'users'}); - $r->print(&mt('Users: ').$curr_user_list); - } else { - $r->print(' '); - } - } else { - $r->print(' '); - } - $r->print(''); - $r->print(&Apache::loncommon::end_data_table_row()); - $count ++; + $todisplay{$scope}{$newkey} = $$updated_controls{$newkey}; } + &build_access_summary($r,$count,$chg,%todisplay); } } $r->print(&Apache::loncommon::end_data_table()); } else { if ((@{$processing{'activate'}} > 0) || (@{$processing{'update'}} > 0)) { - $errors .= &mt('A problem occurred storing access control settings: [_1]',$outcome); + $errors .= ''. + &mt('A problem occurred saving access control settings: [_1]',$outcome). + ''; } } if ($errors) { @@ -669,16 +1024,16 @@ sub update_access { my $totalnew = 0; my $status = 'new'; my ($firstitem,$lastitem); - foreach my $newitem ('course','group','domains','users') { + foreach my $newitem ('course','domains','users') { $allnew += $env{'form.new'.$newitem}; } if ($allnew > 0) { my $now = time; my $then = $now + (60*60*24*180); # six months approx. - &open_form($r,$url,$group); - foreach my $newitem ('course','group','domains','users') { + &open_form($r,$url); + foreach my $newitem ('course','domains','users') { if ($env{'form.new'.$newitem} > 0) { - $r->print('
');
- $r->print(''.&mt('Public access:').' '.$publictext.''); + if ($action eq 'chgaccess') { + &standard_settings($r,$now,$then,$url,$filename,\%acl_count,\%start, + \%end,$public,$publicnum,$publictext,$guest,$guestnum, + $guesttext,$access_controls,%conditionals); + } else { + &condition_setting($r,$access_controls,$now,$then,\%acl_count, + \@domains,\@users,\@courses); + } + $r->print(' |
'.&mt('Action').' | '.&mt('Roles').' | '. - &mt('Access').' | '.&mt('Sections').' | '. - &mt($crsgrptext).' | '.&dateboxes($num,$start,$end)); + my $newrole_id = 1; if ($status eq 'old') { + $r->print(' | '); my $max_id = 0; - foreach my $role_id (sort(keys(%{$content{'roles'}}))) { - if ($role_id > $max_id) { - $max_id = $role_id; - } - $max_id ++; - my $role_selects = &role_selectors($num,$role_id,$status,$type,\%content,'display'); - $r->print(' |
---|---|---|---|---|
'.&mt('Action').' | '. + ''.&mt('Roles').' | '. + ''.&mt('Access').' | '. + ''.&mt('Sections').' | '. + ''.&mt('Groups').' |
---|---|---|---|---|