--- loncom/interface/lonmenu.pm 2012/12/07 17:15:56 1.398
+++ loncom/interface/lonmenu.pm 2012/12/27 05:28:33 1.402
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.398 2012/12/07 17:15:56 raeburn Exp $
+# $Id: lonmenu.pm,v 1.402 2012/12/27 05:28:33 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;
}
@@ -487,8 +492,7 @@ sub innerregister {
}
my $trail;
if ($env{'form.folderpath'}) {
- my $editbutton =
- &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
($trail) =
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
} else {
@@ -525,7 +529,7 @@ sub innerregister {
$editbutton = &prepare_functions($resurl,$forcereg,$group);
}
if ($editbutton eq '') {
- &clear(6,1);
+ $editbutton = &clear(6,1);
}
#
@@ -860,7 +864,7 @@ sub prepare_functions {
$forceedit,$forceview,$forcereg,
$env{'form.title'},$env{'form.suppurl'});
}
- } elsif ($resurl !~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
+ } elsif ($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
($cfile,$home,$switchserver,$forceedit,$forceview) =
@@ -1570,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';
@@ -1658,42 +1662,70 @@ sub roles_selector {
}
}
}
- my $switchtext;
if ($crstype eq 'Community') {
- $switchtext = &mt('Switch community role to...')
+ $switchtext = &mt('Switch community role')
} else {
- $switchtext = &mt('Switch course role to...')
+ $switchtext = &mt('Switch course role')
}
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 {
@@ -1832,9 +1864,8 @@ sub jump_to_role {
return <<"END";