--- loncom/interface/lonhtmlcommon.pm 2006/07/18 21:55:24 1.144 +++ loncom/interface/lonhtmlcommon.pm 2006/12/05 02:55:53 1.155 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.144 2006/07/18 21:55:24 albertel Exp $ +# $Id: lonhtmlcommon.pm,v 1.155 2006/12/05 02:55:53 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,7 +60,6 @@ use Time::Local; use Time::HiRes; use Apache::lonlocal; use Apache::lonnet; -use lib '/home/httpd/lib/perl/'; use LONCAPA; ############################################## @@ -78,7 +77,7 @@ use LONCAPA; sub authorbombs { my $url=shift; $url=&Apache::lonnet::declutter($url); - my ($udom,$uname)=($url=~/^(\w+)\/(\w+)\//); + my ($udom,$uname)=($url=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)/}); my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); foreach (keys %bombs) { if ($_=~/^$udom\/$uname\//) { @@ -689,14 +688,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 +1011,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?'':'
'); } @@ -1045,7 +1045,7 @@ var checkwin; function spellcheckerwindow(string) { var esc_string = string.replace(/\"/g,'"'); checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); - checkwin.document.writeln('$start_page
<\/form>$end_page'); + checkwin.document.writeln('$start_page<\\/form>$end_page'); checkwin.document.close(); } // END LON-CAPA Internal --> @@ -1094,6 +1094,7 @@ _editor_url='/htmlarea/'; _editor_lang='$lang'; + ENDHEADERS } @@ -1264,9 +1265,9 @@ returns: nothing $bug = $last->{'bug'} if (exists($last->{'bug'})); $help = $last->{'help'} if (exists($last->{'help'})); $component_help=($component_help?$component_help:$help); - if ($faq ne '') { - $icons .= &Apache::loncommon::help_open_faq($faq); - } +# if ($faq ne '') { +# $icons .= &Apache::loncommon::help_open_faq($faq); +# } # if ($bug ne '') { # $icons .= &Apache::loncommon::help_open_bug($bug); # } @@ -1417,7 +1418,7 @@ ENDTWO } 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); @@ -1428,10 +1429,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)) { @@ -1584,6 +1600,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; +} + + ############################################## ############################################## @@ -1722,66 +1756,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