--- loncom/interface/lonmenu.pm 2021/03/06 19:58:55 1.369.2.82
+++ loncom/interface/lonmenu.pm 2021/12/13 23:26:32 1.369.2.83
@@ -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 @@ use vars qw(@desklines %category_names %
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 @@ sub prep_menuitem {
} else { # textual Link
$link = &mt($$menuitem[3]);
}
- return '
':'').'$link|;
+ . qq| href="$$menuitem[0]" target="_top" $linkattr>$link|;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -263,6 +263,7 @@ sub prep_menuitem {
# @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 @@ sub primary_menu {
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 @@ sub primary_menu {
} 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} .= ''.&mt($title).'';
+ $menu{$position} .= ($listclass?'':'').
+ ''.&mt($title).'';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -331,13 +338,22 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem);
+ $menu{$position} .= &prep_menuitem($menuitem,$listclass,$linkattr);
}
} else {
- $menu{$position} .= ''.&Apache::loncommon::top_nav_help('Help').'';
+ $menu{$position} .= ($listclass?'':'').
+ &Apache::loncommon::top_nav_help('Help',$linkattr).
+ '';
+ }
+ } 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 getauthor{
}
sub secondary_menu {
- my ($httphost) = @_;
+ my ($httphost,$links_disabled) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -435,6 +451,12 @@ sub secondary_menu {
}
}
+ 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 @@ sub secondary_menu {
}
}
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 .= ''.&mt($title).'';
+ $menu .= ($listclass?'':'').
+ ''.
+ &mt($title).'';
}
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
@@ -539,7 +564,7 @@ sub secondary_menu {
}
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 @@ sub secondary_menu {
}
$$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 secondary_menu {
}
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 @@ sub create_submenu {
# $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 .= '';
return $menu;
@@ -613,7 +638,7 @@ sub create_submenu {
# 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 @@ sub build_submenu {
$target = ' target="_top"';
}
- $menu .= '';
- $menu .= '' . $title . '';
+ $menu .= '';
+ $menu .= '' . $title . '';
$menu .= '';
}
}
@@ -1524,15 +1551,17 @@ sub prepare_functions {
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 @@ sub prepare_functions {
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,