--- loncom/interface/lonmenu.pm 2022/01/03 16:37:24 1.369.2.83.2.1
+++ loncom/interface/lonmenu.pm 2022/03/25 21:25:37 1.369.2.83.4.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.83.2.1 2022/01/03 16:37:24 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.83.4.1 2022/03/25 21:25:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -263,8 +263,8 @@ sub prep_menuitem {
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
- my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled) = @_;
- my (%menu,%menuopts);
+ my ($links_disabled) = @_;
+ my %menu;
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
my $public;
@@ -272,9 +272,6 @@ sub primary_menu {
|| (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
$public = 1;
}
- if (($menucoll) && (ref($menuref) eq 'HASH')) {
- %menuopts = %{$menuref};
- }
foreach my $menuitem (@primary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY'; #
@@ -298,23 +295,6 @@ sub primary_menu {
if ($position eq '') {
$position = 'right';
}
- if ($env{'request.course.id'} && $menucoll) {
- if (($menuitem->[6]) && (!$menuopts{$menuitem->[6]})) {
- if ($menuitem->[6] eq 'pers') {
- if ($menuopts{'name'} &&
- $env{'user.name'} && $env{'user.domain'}) {
- $menu{$position} .= '
'.
- &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'}).'';
- next;
- } else {
- next;
- }
- } else {
- next;
- }
- }
- }
my ($listclass,$linkattr);
if ($links_disabled) {
$listclass = 'LCisDisabled';
@@ -336,30 +316,18 @@ sub primary_menu {
($item->[2] eq 'blog')) &&
(!&Apache::lonnet::usertools_access('','',$item->[2],
undef,'tools')));
- if ($env{'request.course.id'} && $menucoll) {
- next if ($item->[3]) && (!$menuopts{$item->[3]});
- }
push(@primsub,$item);
}
- if ($title eq 'Personal') {
- if ($env{'user.name'} && $env{'user.domain'}) {
- unless (($env{'request.course.id'}) && ($menucoll) && (!$menuopts{'name'})) {
- $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
- }
- }
- next if (($env{'request.course.id'}) && ($menucoll) && ($title eq 'Personal') &&
- (!@primsub));
- if ($title eq 'Personal') {
+ if (@primsub > 0) {
+ if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ } else {
$title = &mt($title);
}
- } else {
- $title = &mt($title);
- }
- if (@primsub > 0) {
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1,undef,$listclass,$linkattr);
} elsif ($link) {
$menu{$position} .= ($listclass?'':'').
- ''.$title.'';
+ ''.&mt($title).'';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -424,7 +392,7 @@ sub getauthor{
}
sub secondary_menu {
- my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,$links_disabled) = @_;
+ my ($httphost,$links_disabled) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -445,10 +413,9 @@ sub secondary_menu {
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
- my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
- my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,%menuopts);
+ my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools);
$grouptools = 0;
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -483,9 +450,6 @@ sub secondary_menu {
}
}
}
- if (($menucoll) && (ref($menuref) eq 'HASH')) {
- %menuopts = %{$menuref};
- }
my ($listclass,$linkattr);
if ($links_disabled) {
@@ -538,21 +502,12 @@ sub secondary_menu {
&& !$showsyllabus;
next if $$menuitem[4] eq 'showfeeds'
&& !$showfeeds;
- next if $$menuitem[4] eq 'plc'
- && !$canplc;
next if $$menuitem[4] eq 'author'
&& !$author;
next if $$menuitem[4] eq 'cca'
&& !$canmodifycoauthor;
my $title = $menuitem->[3];
- if ($env{'request.course.id'} && $menucoll) {
- if ($$menuitem[5] eq 'main') {
- next if ($menuopts{$$menuitem[5]} eq 'n');
- } elsif ($$menuitem[5] ne 'roles') {
- next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]}));
- }
- }
if (defined($secondary_submenu{$title})) {
my ($link,$target);
if ($menuitem->[0] ne '') {
@@ -589,16 +544,12 @@ sub secondary_menu {
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- my ($switcher,$has_opa_priv);
- ($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) =
+ ($roleswitcher_js,$roleswitcher_form,my $switcher) =
&roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'},
$httphost
);
- if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
- next unless ($has_opa_priv);
- }
$menu .= $switcher;
} else {
if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
@@ -648,7 +599,6 @@ sub secondary_menu {
}
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
- $menu =~ s/\[javascript\]/javascript:/g;
if ($env{'request.course.id'}) {
$menu =~ s/\[cnum\]/$cnum/g;
$menu =~ s/\[cdom\]/$cdom/g;
@@ -1097,15 +1047,13 @@ if ($env{'browser.mobile'}) {
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) &&
- ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)}) &&
- ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) {
+ ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)})) {
$menuitems.=(< 1) {
$include = 1;
- } else {
- if ($env{'user.priv.'.$env{'request.role'}."./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
- $has_opa_priv = 1;
- }
}
} else {
$include = 1;
}
}
if ($include) {
- if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
- $has_opa_priv = 1;
- }
push(@submenu,['javascript:adhocRole('."'$role'".')',
&Apache::lonnet::plaintext($role,$crstype)]);
}
@@ -2922,9 +2862,6 @@ sub roles_selector {
} else {
$rolename = &Apache::lonnet::plaintext($role);
}
- if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) {
- $has_opa_priv = 1;
- }
push(@submenu,['javascript:adhocRole('."'$role'".')',
$rolename]);
}
@@ -2934,7 +2871,7 @@ sub roles_selector {
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu);
}
}
- return ($js,$form,$switcher,$has_opa_priv);
+ return ($js,$form,$switcher);
}
sub get_all_courseroles {
@@ -3365,13 +3302,13 @@ BEGIN {
$category_positions{$entries[2]}=$entries[1];
$category_names{$entries[2]}=$entries[3];
} elsif ($configline=~/^prim\:/) {
- my @entries = (split(/\:/, $configline))[1..7];
+ my @entries = (split(/\:/, $configline))[1..6];
push(@primary_menu,\@entries);
} elsif ($configline=~/^primsub\:/) {
- my ($parent,@entries) = (split(/\:/, $configline))[1..5];
+ my ($parent,@entries) = (split(/\:/, $configline))[1..4];
push(@{$primary_submenu{$parent}},\@entries);
} elsif ($configline=~/^scnd\:/) {
- my @entries = (split(/\:/, $configline))[1..6];
+ my @entries = (split(/\:/, $configline))[1..5];
push(@secondary_menu,\@entries);
} elsif ($configline=~/^scndsub\:/) {
my ($parent,@entries) = (split(/\:/, $configline))[1..4];