--- loncom/interface/portfolio.pm 2006/06/22 15:46:28 1.111 +++ loncom/interface/portfolio.pm 2006/06/22 20:09:51 1.119 @@ -31,7 +31,7 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; -use lib '/home/httpd/lib/perl'; +use HTML::Entities; use LONCAPA; # receives a file name and path stub from username/userfiles/portfolio/ @@ -40,9 +40,9 @@ 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.''; return $anchor; @@ -63,42 +63,43 @@ sub display_common { 'createdir' => 'Create Subdirectory', 'createdir_label' => 'Create subdirectory in current directory:'); + my $escuri = &HTML::Entities::encode($r->uri,'&<>"'); $r->print(<<"TABLE"); - - - - -
- $text{'upload_label'} - $groupitem + + + + - - - - - - + + + + - - + + +
+ $text{'upload_label'} + $groupitem + -
- $text{'createdir_label'} - + +
+ $text{'createdir_label'} + +
$groupitem -
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"},$group).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @tree; $i++){ @@ -106,11 +107,11 @@ TABLE $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/'); } } - $r->print(''); + $r->print(''); &Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path); - $r->print('
'. &Apache::lonhtmlcommon::select_recent($namespace,'currentpath', @@ -153,13 +154,13 @@ sub display_directory { return; } if ($select_mode eq 'true') { - $r->print(''. - ''); $r->print(''); + $r->print('
Select NameSizeLast Modified
'. + ''); } else { - $r->print('
Select NameSizeLast Modified
'. - ''); $r->print(''); + $r->print('
Actions NameSizeLast ModifiedCurrent Access Status
'. + ''); } if (defined($group)) { $r->print("\n".$groupitem."\n"); @@ -189,16 +190,17 @@ sub display_directory { my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename); if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) { if ($dirptr&$testdir) { + my $colspan='colspan="2"'; if ($select_mode eq 'true'){ - $r->print(''); - } else { - $r->print(''); + undef($colspan); } + $r->print(''); $r->print(''); $r->print(''); $r->print(''); } else { - $r->print(''); + my $css_class = 'LC_browser_file'; + my $line; my $version_flag; if (exists($versioned{$fname})) { $version_flag = "*"; @@ -208,22 +210,25 @@ sub display_directory { my $fullpath = $current_path.$filename; $fullpath = &prepend_group($fullpath,$group); if ($select_mode eq 'true'){ - $r->print(''); + $line.=' />'; } else { if (exists $locked_files{$fullpath}) { - $r->print(''); + $line.=''; + $css_class= 'LC_browser_file_locked'; } else { my $cat=''.&mt('Catalog Information').
 			    ''; - $r->print(''); + '; } + $r->print(''); + $r->print($line); } my $curr_access; my $pub_access = 0; @@ -256,15 +261,15 @@ sub display_directory { } $curr_access = join('+ ',@allaccesses); } - $r->print(''); + $r->print(''); $r->print(''); $r->print(''); $r->print(''); - $r->print(''); + '">'.&mt('View/Change').''); $r->print(''); } } @@ -316,7 +321,7 @@ sub close_form { $group.'" />'); } $r->print('

'); - $r->print(' + $r->print('

'); @@ -331,16 +336,20 @@ sub close_form { sub display_file { my ($path,$filename)=@_; my $display_file_text; + my $file_start=''; + my $file_end=''; if (!defined($path)) { $path=$env{'form.currentpath'}; } if (!defined($filename)) { $filename=$env{'form.selectfile'}; - $display_file_text = ''.$path.$filename.''; + $display_file_text = $file_start.$path.$filename.$file_end; } elsif (ref($filename) eq "ARRAY") { - foreach (@$filename) { - $display_file_text .= ''.$path.$_.'
'; + foreach my $file (@$filename) { + $display_file_text .= $file_start.$path.$file.$file_end.'
'; } } elsif (ref($filename) eq "SCALAR") { - $display_file_text = ''.$path.$filename.''; + $display_file_text = $file_start.$path.$$filename.$file_end; + } else { + $display_file_text = $file_start.$path.$filename.$file_end; } return $display_file_text; } @@ -394,8 +403,8 @@ sub delete_confirmed { $env{'form.currentpath'}. $delete_file); if ($result ne 'ok') { - $r->print(' An error occured ('.$result. - ') while trying to delete '.&display_file(undef, $delete_file).'
'); + $r->print(' An error occured ('.$result. + ') while trying to delete '.&display_file(undef, $delete_file).'
'); } } $r->print(&done(undef,$url,$group)); @@ -419,8 +428,8 @@ sub delete_dir_confirmed { $directory_name); if ($result ne 'ok') { - $r->print(' An error occured (dir) ('.$result. - ') while trying to delete '.$directory_name.'
'); + $r->print(' An error occured (dir) ('.$result. + ') while trying to delete '.$directory_name.'
'); } else { # now remove from recent # $r->print('
removing '.$directory_name.'
print(''. + $r->print(''. &mt("Error: no valid filename was provided to rename to."). - '
'); + '
'); $r->print(&done(undef,$url,$group)); return; } @@ -470,12 +479,15 @@ sub rename_confirmed { $port_path.$env{'form.currentpath'}.$env{'form.selectfile'}, $port_path.$env{'form.currentpath'}.$filenewname); if ($result ne 'ok') { - $r->print(' An errror occured ('.$result. - ') while trying to rename '.&display_file().' to '. - &display_file(undef,$filenewname).'
'); + $r->print(''. + &mt('An errror occured ([_1]) while trying to rename [_2]' + .' to [_3]',$result,&display_file(), + &display_file('',$filenewname)).'
'); } if ($filenewname ne $env{'form.filenewname'}) { - $r->print("The new file name was changed from:
".$env{'form.filenewname'}." to $filenewname "); + $r->print(&mt("The new file name was changed from:
[_1] to [_2]", + ''.&display_file('',$env{'form.filenewname'}).'', + ''.&display_file('',$filenewname).'')); } $r->print(&done(undef,$url,$group)); } @@ -501,8 +513,6 @@ sub display_access { sub update_access { my ($r,$url,$group) = @_; - my $function = &Apache::loncommon::get_users_function(); - my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); my $totalprocessed = 0; my %processing; my %title = ( @@ -556,7 +566,9 @@ sub update_access { if (@{$processing{$chg}} > 0) { if ($chg eq 'delete') { if (!($deloutcome eq 'ok')) { - $errors .= &mt('A problem occurred deleting access controls: [_1]',$deloutcome); + $errors .=''. + &mt('A problem occurred deleting access controls: [_1]',$deloutcome). + ''; next; } } @@ -600,8 +612,7 @@ sub update_access { if ($scope eq 'guest') { $r->print(&mt('Password').': '.$content->{'password'}); } elsif ($scope eq 'course' || $scope eq 'group') { - $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).'
print("CHECKED"); + $line='print('>LockedLocked + $line.=' Rename '.$cat.' -
'. $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''.&mt($curr_access).'   '. + $r->print(''.&mt($curr_access).'   '. ''.&mt('View/Change').'
'); + $r->print('
'); $r->print(''); @@ -658,7 +669,9 @@ sub update_access { $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 storing access control settings: [_1]',$outcome). + ''; } } if ($errors) { @@ -693,7 +706,7 @@ sub update_access { &close_form($r,$url,$group); } else { $r->print('
'. + '&currentpath='.$env{'form.currentpath'}.'">'. &mt('Display all access settings for this file').''); } return; @@ -921,7 +934,6 @@ sub display_access_row { my ($r,$status,$type,$items,$access_controls,$now,$then) = @_; if (@{$items} > 0) { my @all_doms; - my $tablecolor; my $colspan = 3; my $uctype = $type; $uctype =~ s/^(\w)/uc($1)/e; @@ -933,25 +945,22 @@ sub display_access_row { $r->print(''); $colspan ++; - my $function = &Apache::loncommon::get_users_function(); - $tablecolor=&Apache::loncommon::designparm($function.'.tabbg'); } elsif ($type eq 'domains') { @all_doms = &Apache::loncommon::get_domains(); } $r->print(&Apache::loncommon::end_data_table_header_row()); - $r->print(&Apache::loncommon::start_data_table_row()); foreach my $key (@{$items}) { + $r->print(&Apache::loncommon::start_data_table_row()); if (($type eq 'course') || ($type eq 'group')) { - &course_row($r,$status,$type,$key,$access_controls, - $tablecolor,$now,$then); + &course_row($r,$status,$type,$key,$access_controls,$now,$then); } elsif ($type eq 'domains') { &domains_row($r,$status,$key,\@all_doms,$access_controls,$now, $then); } elsif ($type eq 'users') { &users_row($r,$status,$key,$access_controls,$now,$then); } + $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print(&Apache::loncommon::end_data_table_row()); if ($status eq 'old') { $r->print(&Apache::loncommon::start_data_table_row()); $r->print(''); if ($status eq 'old') { - my $cid = $content{'domain'}.'_'.$content{'number'}; + my $cid = $content->{'domain'}.'_'.$content->{'number'}; my %course_description = &Apache::lonnet::coursedescription($cid); - $r->print(''); + $r->print(''); } elsif ($status eq 'new') { my $uctype = $type; $uctype =~ s/^(\w)/uc($1)/e; $r->print(''); } $r->print(''); - $r->print(''); } elsif ($status eq 'new') { my $role_id = 1; my $role_selects = &role_selectors($num,$role_id,$status,$type,undef,'display'); @@ -1063,7 +1073,7 @@ sub domains_row { my ($r,$status,$item,$all_doms,$access_controls,$now,$then) = @_; my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, 'domains'); - my $dom_select = ''. ' '; if ($status eq 'old') { my $content = $$access_controls{$item}; @@ -1081,6 +1091,7 @@ sub domains_row { $dom_select .= ''; } } + $dom_select .= ''; $r->print(''); } @@ -1105,17 +1116,17 @@ sub additional_item { sub actionbox { my ($status,$num,$scope) = @_; - my $output = ''. + '" />'.&mt('Delete').'
'. '
'; + $output .= ''; return $output; } @@ -1130,10 +1141,10 @@ sub dateboxes { undef,undef,1); my $enddate = &Apache::lonhtmlcommon::date_setter('portform', 'enddate_'.$num,$end,undef,undef,undef,1,undef, - undef,undef,1). '  '; + ''; my $output = &mt('Start: ').$startdate.'
'.&mt('End: ').$enddate; return $output; @@ -1276,7 +1287,7 @@ sub select_files { $java_files.=','; } my $javascript =(< +
'.&mt('Roles').''. &mt('Access').''. &mt('Sections').''.&mt('Allowed [_1] member affiliations',$type). ''.&additional_item($type). @@ -1010,11 +1019,12 @@ function getIndex(name,value) { } sub course_row { - my ($r,$status,$type,$item,$access_controls,$tablecolor,$now,$then) = @_; - my %content; + my ($r,$status,$type,$item,$access_controls,$now,$then) = @_; + my $content; my $defdom = $env{'user.domain'}; if ($status eq 'old') { - $defdom = $$access_controls{$item}{'domain'}; + $content = $$access_controls{$item}; + $defdom = $content->{'domain'}; } my $js = &Apache::loncommon::coursebrowser_javascript($defdom) .&course_js(); @@ -1026,30 +1036,30 @@ sub course_row { $type); $r->print(''.$js.&actionbox($status,$num,$scope).''.$course_description{'description'}.''.$course_description{'description'}.''.&Apache::loncommon::selectcourse_link('portform','crsnum_'.$num,'crsdom_'.$num,'description_'.$num,undef,undef,$uctype).'  '.&dateboxes($num,$start,$end).''); + $r->print(''); + $r->print('
'); $r->print(''); if ($status eq 'old') { my $max_id = 0; - foreach my $role_id (sort(keys(%{$content{'roles'}}))) { + 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(''.$role_selects.''); + my $role_selects = &role_selectors($num,$role_id,$status,$type,$content,'display'); + $r->print(''.$role_selects.''); } - $r->print('
'.&mt('Action').''.&mt('Roles').''. &mt('Access').''.&mt('Sections').''. &mt($crsgrptext).'



'.&mt('Add a roles-based condition').' 

'.&mt('Add a roles-based condition').' {'domain'}','$content->{'number'}','Course'".')" value="'.$max_id.'" />
'.&actionbox($status,$num,$scope).''.$dom_select. ''.&dateboxes($num,$start,$end).'