[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm
raeburn
raeburn at source.lon-capa.org
Mon Dec 13 18:26:32 EST 2021
raeburn Mon Dec 13 23:26:32 2021 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonmenu.pm
Log:
- For 2.11
Backport 1.504, 1.506, 1.510, 1.511, 1.512, 1.513, 1.514
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.82 loncom/interface/lonmenu.pm:1.369.2.83
--- loncom/interface/lonmenu.pm:1.369.2.82 Sat Mar 6 19:58:55 2021
+++ loncom/interface/lonmenu.pm Mon Dec 13 23:26:32 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.82 2021/03/06 19:58:55 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.83 2021/12/13 23:26:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -240,7 +240,7 @@
my @inlineremote;
sub prep_menuitem {
- my ($menuitem) = @_;
+ my ($menuitem,$listclass,$linkattr) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
my $link;
if ($$menuitem[1]) { # graphical Link
@@ -250,10 +250,10 @@
} else { # textual Link
$link = &mt($$menuitem[3]);
}
- return '<li><a'
+ return ($listclass?'<li class="'.$listclass.'">':'<li>').'<a'
# highlighting for new messages
. ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '')
- . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
+ . qq| href="$$menuitem[0]" target="_top" $linkattr>$link</a></li>|;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -263,6 +263,7 @@
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
+ my ($links_disabled) = @_;
my %menu;
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
@@ -294,6 +295,11 @@
if ($position eq '') {
$position = 'right';
}
+ my ($listclass,$linkattr);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
if (defined($primary_submenu{$title})) {
my ($link,$target);
if ($menuitem->[0] ne '') {
@@ -318,9 +324,10 @@
} else {
$title = &mt($title);
}
- $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1);
+ $menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1,undef,$listclass,$linkattr);
} elsif ($link) {
- $menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
+ $menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>').
+ '<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'.&mt($title).'</a></li>';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -331,13 +338,22 @@
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem);
+ $menu{$position} .= &prep_menuitem($menuitem,$listclass,$linkattr);
}
} else {
- $menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
+ $menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>').
+ &Apache::loncommon::top_nav_help('Help',$linkattr).
+ '</li>';
}
+ } elsif ($$menuitem[3] eq 'Log In') {
+ if ($public) {
+ if (&Apache::lonnet::get_saml_landing()) {
+ $$menuitem[0] = '/adm/login';
+ }
+ }
+ $menu{$position} .= prep_menuitem($menuitem,$listclass,$linkattr);
} else {
- $menu{$position} .= prep_menuitem($menuitem);
+ $menu{$position} .= prep_menuitem($menuitem,$listclass,$linkattr);
}
}
my @output = ('','');
@@ -376,7 +392,7 @@
}
sub secondary_menu {
- my ($httphost) = @_;
+ my ($httphost,$links_disabled) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -435,6 +451,12 @@
}
}
+ my ($listclass,$linkattr);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
+
my ($canmodifycoauthor);
if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
my $extent = "$env{'user.domain'}/$env{'user.name'}";
@@ -512,9 +534,12 @@
}
}
if (@scndsub > 0) {
- $menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1);
+ $menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1,undef,
+ $listclass,$linkattr);
} elsif ($link ne '#') {
- $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
+ $menu .= ($listclass?'<li class="'.$listclass.'">':'<li>').
+ '<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'.
+ &mt($title).'</a></li>';
}
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
@@ -539,7 +564,7 @@
}
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) {
unless ($$menuitem[0] =~ m{^https?://}) {
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
}
@@ -551,7 +576,7 @@
}
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
- $menu .= &prep_menuitem(\@$menuitem);
+ $menu .= &prep_menuitem(\@$menuitem,$listclass,$linkattr);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -588,7 +613,7 @@
}
sub create_submenu {
- my ($link,$target,$title,$submenu,$translate,$addclass) = @_;
+ my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_;
return unless (ref($submenu) eq 'ARRAY');
my $disptarget;
if ($target ne '') {
@@ -603,7 +628,7 @@
# $link and $title are only used in the initial string written in $menu
# as seen above, not needed for nested submenus
- $menu .= &build_submenu($target, $submenu, $translate, '1');
+ $menu .= &build_submenu($target, $submenu, $translate, '1', $listclass, $linkattr);
$menu .= '</ul></li>';
return $menu;
@@ -613,7 +638,7 @@
# build the dropdown (and nested submenus) recursively
# see perldoc create_submenu documentation for further information
sub build_submenu {
- my ($target, $submenu, $translate, $first_level) = @_;
+ my ($target, $submenu, $translate, $first_level, $listclass, $linkattr) = @_;
unless (@{$submenu}) {
return '';
}
@@ -676,8 +701,10 @@
$target = ' target="_top"';
}
- $menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">';
- $menu .= '<a href="'.$href.'"'.$target.'>' . $title . '</a>';
+ $menu .= '<li ';
+ $menu .= ($listclass?'class="'.$listclass.'" ':'');
+ $menu .= 'style="margin:0;padding:0;'. $bordertop . $borderbot .'">';
+ $menu .= '<a href="'.$href.'"'.$target.' '.$linkattr.'>' . $title . '</a>';
$menu .= '</li>';
}
}
@@ -1524,15 +1551,17 @@
my $editbutton = '';
my $viewsrcbutton = '';
+ my $clientip = &Apache::lonnet::get_requestor_ip();
#
# Determine whether or not to display 'Edit' or 'View Source' icon/button
#
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
+ my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$2,$1);
my $file=&Apache::lonnet::declutter($env{'request.filename'});
($cfile,$home,$switchserver,$forceedit,$forceview) =
&Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
- if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
+ if (($cfile) && ($home ne '') && ($home ne 'no_host') && (!$blocked)) {
$editbutton = &get_editbutton($cfile,$home,$switchserver,
$forceedit,$forceview,$forcereg);
}
@@ -1645,10 +1674,13 @@
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
my ($sdom,$sname) = ($1,$2);
unless (&Apache::lonnet::is_course($sdom,$sname)) {
- &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
- '',
- "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
- 'Send message to specific user','','',1);
+ my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$sname,$sdom);
+ unless ($blocked) {
+ &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
+ '',
+ "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
+ 'Send message to specific user','','',1);
+ }
}
my $hideprivileged = 1;
if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
More information about the LON-CAPA-cvs
mailing list