--- loncom/interface/lonmenu.pm 2012/12/26 23:50:26 1.400
+++ loncom/interface/lonmenu.pm 2012/12/27 00:24:45 1.401
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.400 2012/12/26 23:50:26 raeburn Exp $
+# $Id: lonmenu.pm,v 1.401 2012/12/27 00:24:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -331,6 +331,8 @@ sub secondary_menu {
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'});
+ my ($roleswitcher_js,$roleswitcher_form);
+
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
@@ -363,12 +365,12 @@ sub secondary_menu {
if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- my $roles_selector = &roles_selector(
+ ($roleswitcher_js,$roleswitcher_form,my $switcher) =
+ &roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'} );
-
- $menu .= $roles_selector ? "
$roles_selector"
- : '';
+ $env{'course.' . $env{'request.course.id'} . '.num'}
+ );
+ $menu .= $switcher;
} else {
$menu .= &prep_menuitem(\@$menuitem);
}
@@ -396,6 +398,9 @@ sub secondary_menu {
if ($menu) {
$menu = "";
}
+ if ($roleswitcher_form) {
+ $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
+ }
return $menu;
}
@@ -1569,7 +1574,7 @@ sub roles_selector {
my $now = time;
my (%courseroles,%seccount,%courseprivs);
my $is_cc;
- my $role_selector;
+ my ($js,$form,$switcher,$switchtext);
my $ccrole;
if ($crstype eq 'Community') {
$ccrole = 'co';
@@ -1657,7 +1662,6 @@ sub roles_selector {
}
}
}
- my $switchtext;
if ($crstype eq 'Community') {
$switchtext = &mt('Switch community role to...')
} else {
@@ -1665,34 +1669,34 @@ sub roles_selector {
}
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
if (keys(%courseroles) > 1) {
- $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
- $role_selector .= '';
}
- return $role_selector;
+ return ($js,$form,$switcher);
}
sub get_all_courseroles {
@@ -1831,9 +1835,8 @@ sub jump_to_role {
return <<"END";