[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm
raeburn
raeburn at source.lon-capa.org
Sat May 28 11:55:34 EDT 2022
raeburn Sat May 28 15:55:34 2022 EDT
Modified files:
/loncom/interface lonmenu.pm
Log:
- "Switch role" in course context for users with acces to multiple roles in
the current course will offer to default to /adm/navmaps not /adm/menu if
Main Menu is disabled in menu collection currently in effect.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.518 loncom/interface/lonmenu.pm:1.519
--- loncom/interface/lonmenu.pm:1.518 Fri May 27 04:35:36 2022
+++ loncom/interface/lonmenu.pm Sat May 28 15:55:34 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.518 2022/05/27 04:35:36 raeburn Exp $
+# $Id: lonmenu.pm,v 1.519 2022/05/28 15:55:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -657,7 +657,7 @@
&roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost
+ $httphost,$menucoll,$menuref
);
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
next unless ($has_opa_priv);
@@ -2526,7 +2526,7 @@
}
sub roles_selector {
- my ($cdom,$cnum,$httphost) = @_;
+ my ($cdom,$cnum,$httphost,$menucoll,$menuref) = @_;
my $crstype = &Apache::loncommon::course_type();
my $now = time;
my (%courseroles,%seccount,%courseprivs,%roledesc);
@@ -2633,7 +2633,8 @@
}
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
my @submenu;
- $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref);
+ $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,
+ \%roledesc,$privref,$menucoll,$menuref);
$form =
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n".
' <input type="hidden" name="destinationurl" value="'.
@@ -2868,7 +2869,8 @@
}
sub jump_to_role {
- my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_;
+ my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref,
+ $menucoll,$menuref) = @_;
my %lt = &Apache::lonlocal::texthash(
this => 'This role has section(s) associated with it.',
ente => 'Enter a specific section.',
@@ -2879,6 +2881,7 @@
role => 'The role you selected is not permitted to view the current page.',
swit => 'Switch role, but display Main Menu page instead?',
);
+ &js_escape(\%lt);
my $js;
if (ref($courseroles) eq 'HASH') {
$js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n".
@@ -2901,6 +2904,8 @@
}
}
my $checkroles = 0;
+ my $fallback = '/adm/menu';
+ my $displaymsg = $lt{'swit'};
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) {
my %disallowed;
foreach my $role (sort(keys(%{$courseprivs}))) {
@@ -2922,8 +2927,22 @@
$checkroles = 1;
$js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n".
" var rolecheck = 1;\n";
+ if ($menucoll) {
+ if (ref($menuref) eq 'HASH') {
+ if ($menuref->{'main'} eq 'n') {
+ $fallback = '/adm/navmaps';
+ if (&Apache::loncommon::course_type() eq 'Community') {
+ $displaymsg = &mt('Switch role, but display Community Contents page instead?');
+ } else {
+ $displaymsg = &mt('Switch role, but display Course Contents page instead?');
+ }
+ &js_escape(\$displaymsg);
+ }
+ }
+ }
}
}
+ &js_escape(\$fallback);
if (!$checkroles) {
$js .= " var disallow = new Array();\n".
" rolecheck = 0;\n";
@@ -2946,8 +2965,8 @@
if (rolecheck > 0) {
for (var i=0; i<disallow.length; i++) {
if (disallow[i] == newrole) {
- if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
- document.rolechooser.destinationurl.value = '/adm/menu';
+ if (confirm("$lt{'role'}\\n$displaymsg")) {
+ document.rolechooser.destinationurl.value = '$fallback';
} else {
return;
}
More information about the LON-CAPA-cvs
mailing list