--- loncom/interface/lonhtmlcommon.pm 2006/07/07 13:40:16 1.142 +++ loncom/interface/lonhtmlcommon.pm 2006/08/08 19:10:54 1.152 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.142 2006/07/07 13:40:16 albertel Exp $ +# $Id: lonhtmlcommon.pm,v 1.152 2006/08/08 19:10:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -689,14 +689,6 @@ sub StatusOptions { $status = $env{'form.Status'} if (exists($env{'form.Status'})); } - my $OpSel1 = ''; - my $OpSel2 = ''; - my $OpSel3 = ''; - - if($status eq 'Any') { $OpSel3 = ' selected'; } - elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; } - else { $OpSel1 = ' selected'; } - my $Str = ''; $Str .= ''."\n"; } @@ -1014,9 +1012,12 @@ sub crumbs { $output.=qq{$dir/}; } } else { - $output.=$uri; + foreach my $dir (split('/',$uri)) { + if (! $dir) { next; } + $output.=$dir.'/'; + } } - unless ($uri=~/\/$/) { $output=~s/\/$//; } + if ($uri !~ m|/$|) { $output=~s|/$||; } return $output.''.($noformat?'':'
'); } @@ -1094,6 +1095,7 @@ _editor_url='/htmlarea/'; _editor_lang='$lang'; + ENDHEADERS } @@ -1270,20 +1272,21 @@ returns: nothing # if ($bug ne '') { # $icons .= &Apache::loncommon::help_open_bug($bug); # } - if ($helplink ne 'nohelp') { + if ($faq ne '' || $component_help ne '' || $bug ne '') { $icons .= &Apache::loncommon::help_open_menu($component, $component_help, $faq,$bug); } - if ($icons ne '') { - $Str .= $icons.' '; - } # $Str .= $links.''; # if (defined($component)) { $Str .= ''. - &mt($component).''; + &mt($component); + if ($icons ne '') { + $Str .= ' '.$icons; + } + $Str .= ''; } $Str .= ''."\n"; # @@ -1399,19 +1402,24 @@ ENDONE } sub row_closure { + my ($no_separator) =@_; my $output = <<"ENDTWO"; +ENDTWO + if (!$no_separator) { + $output .= <<"ENDTWO"; - + ENDTWO + } return $output; } sub role_select_row { - my ($roles,$title,$css_class) = @_; + my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_; my $output; if (defined($title)) { $output = &row_title($title,$css_class); @@ -1422,10 +1430,25 @@ sub role_select_row { my $plrole; if ($role eq 'ow') { $plrole = &mt('Course Owner'); + } elsif ($role eq 'cr') { + if ($show_separate_custom) { + if ($cdom ne '' && $cnum ne '') { + my %course_customroles = &course_custom_roles($cdom,$cnum); + foreach my $crrole (sort(keys(%course_customroles))) { + my ($plcrrole) = ($crrole =~ m|^cr/[^/]+/[^/]+/(.+)$|); + $output .= ' '; + } + } + } else { + $plrole = &mt('Custom Role'); + } } else { $plrole=&Apache::lonnet::plaintext($role); } - $output .= ' '; + if (($role ne 'cr') || (!$show_separate_custom)) { + $output .= ' '; + } } $output .= qq| \n|; if (defined($title)) { @@ -1578,6 +1601,24 @@ sub submit_row { return $output; } +sub course_custom_roles { + my ($cdom,$cnum) = @_; + my %returnhash=(); + my %coursepersonnel=&Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); + foreach my $person (sort(keys(%coursepersonnel))) { + my ($role) = ($person =~ /^([^:]+):/); + my ($end,$start) = split(/:/,$coursepersonnel{$person}); + if ($end == -1 && $start == -1) { + next; + } + if ($role =~ m|^cr/[^/]+/[^/]+/[^/]|) { + $returnhash{$role} ++; + } + } + return %returnhash; +} + + ############################################## ############################################## @@ -1716,66 +1757,66 @@ sub set_form_elements { my $valuestring = join('","',@{$values{$name}}); $output .= qq| var textvalues = new Array ("$valuestring"); - var total = courseForm.$name.length; + var total = courseForm.elements['$name'].length; if (total > $numvalues) { total = $numvalues; } for (var i=0; i