--- loncom/interface/lonmenu.pm 2009/04/17 15:54:59 1.259 +++ loncom/interface/lonmenu.pm 2009/05/06 12:13:18 1.262 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.259 2009/04/17 15:54:59 bisitz Exp $ +# $Id: lonmenu.pm,v 1.262 2009/05/06 12:13:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -989,8 +989,9 @@ sub load_remote_msg { ($env{'environment.remote'} eq 'off')) { return ''; } my $esclowerurl=&escape($lowerurl); - my $link=&mt('Continue on in Inline Menu mode', - "/adm/remote?action=collapse&url=$esclowerurl"); + my $link=&mt('[_1]Continue[_2] on in Inline Menu mode' + ,'' + ,''); return(<
@@ -1543,16 +1544,16 @@ function set_bookmark() { bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); bmquery.document.write( '$start_page_bookmark' - +"
\\n
Link Name:
" - +"
Address:

<\\/center><\\/td>" - +"<\\/tr><\\/table><\\/form><\\/center>" + +'
' + +'
Link Name:
' + +'
Address:

' +'$end_page_bookmark' ); bmquery.document.close(); } @@ -1628,7 +1629,7 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; my $now = time; - my (%courseroles,%seccount,%gotnosection); + my (%courseroles,%seccount); my $is_cc; my $role_selector; if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { @@ -1643,35 +1644,9 @@ sub roles_selector { } } if ($is_cc) { - my %adv_roles = - &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); - foreach my $role (keys(%adv_roles)) { - my ($urole,$usec) = split(/:/,$role); - if (!$gotnosection{$urole}) { - $seccount{$urole} ++; - $gotnosection{$urole} = 1; - } - if (ref($courseroles{$urole}) eq 'ARRAY') { - if ($usec ne '') { - if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) { - push(@{$courseroles{$urole}},$usec); - $seccount{$urole} ++; - } - } - } else { - @{$courseroles{$urole}} = (); - if ($usec ne '') { - $seccount{$urole} ++; - push(@{$courseroles{$urole}},$usec); - } - } - } - my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); - @{$courseroles{'st'}} = (); - if (keys(%sections_count) > 0) { - push(@{$courseroles{'st'}},keys(%sections_count)); - } + &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount); } else { + my %gotnosection; foreach my $item (keys(%env)) { if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; @@ -1729,6 +1704,61 @@ sub roles_selector { return $role_selector; } +sub get_all_courseroles { + my ($cdom,$cnum,$courseroles,$seccount) = @_; + unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) { + return; + } + my ($result,$cached) = + &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum); + if (defined($cached)) { + if (ref($result) eq 'HASH') { + if ((ref($result->{'roles'}) eq 'HASH') && + (ref($result->{'seccount'}) eq 'HASH')) { + %{$courseroles} = %{$result->{'roles'}}; + %{$seccount} = %{$result->{'seccount'}}; + return; + } + } + } + my %gotnosection; + my %adv_roles = + &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); + foreach my $role (keys(%adv_roles)) { + my ($urole,$usec) = split(/:/,$role); + if (!$gotnosection{$urole}) { + $seccount->{$urole} ++; + $gotnosection{$urole} = 1; + } + if (ref($courseroles->{$urole}) eq 'ARRAY') { + if ($usec ne '') { + if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) { + push(@{$courseroles->{$urole}},$usec); + $seccount->{$urole} ++; + } + } + } else { + @{$courseroles->{$urole}} = (); + if ($usec ne '') { + $seccount->{$urole} ++; + push(@{$courseroles->{$urole}},$usec); + } + } + } + my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']); + @{$courseroles->{'st'}} = (); + if (keys(%sections_count) > 0) { + push(@{$courseroles->{'st'}},keys(%sections_count)); + $seccount->{'st'} = scalar(keys(%sections_count)); + } + my $rolehash = { + 'roles' => $courseroles, + 'seccount' => $seccount, + }; + &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash); + return; +} + sub jump_to_role { my ($cdom,$cnum,$seccount,$courseroles) = @_; my %lt = &Apache::lonlocal::texthash(