--- loncom/interface/lonmenu.pm 2021/06/07 05:59:43 1.508
+++ loncom/interface/lonmenu.pm 2022/05/06 19:36:09 1.515
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.508 2021/06/07 05:59:43 raeburn Exp $
+# $Id: lonmenu.pm,v 1.515 2022/05/06 19:36:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -220,7 +220,7 @@ use vars qw(@desklines %category_names %
my @inlineremote;
sub prep_menuitem {
- my ($menuitem,$ltitarget) = @_;
+ my ($menuitem,$ltitarget,$listclass,$linkattr) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
my $link;
if ($$menuitem[1]) { # graphical Link
@@ -234,10 +234,10 @@ sub prep_menuitem {
if ($ltitarget eq 'iframe') {
$target ='';
}
- return '
':'').'$link |;
+ . qq| href="$$menuitem[0]"$target $linkattr>$link |;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -247,7 +247,7 @@ 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) = @_;
+ my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled) = @_;
my (%menu,%ltiexc,%menuopts);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
@@ -295,10 +295,10 @@ sub primary_menu {
# users
next if $$menuitem[4] eq 'roles' ##show links depending on
&& (&Apache::loncommon::show_course() ##term 'Courses' or
- || $env{'request.lti.login'}); ##'Roles' wanted
+ || $lti); ##'Roles' wanted
next if $$menuitem[4] eq 'courses' ##and not LTI access
&& (!&Apache::loncommon::show_course()
- || !$env{'request.lti.login'});
+ || $lti);
next if $$menuitem[4] eq 'notlti'
&& $lti;
next if $$menuitem[4] eq 'ltiexc'
@@ -332,6 +332,11 @@ sub primary_menu {
}
}
}
+ my ($listclass,$linkattr);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
if (defined($primary_submenu{$title})) {
my ($link,$target);
if ($menuitem->[0] ne '') {
@@ -364,13 +369,17 @@ sub primary_menu {
}
next if (($env{'request.course.id'}) && ($menucoll) && ($title eq 'Personal') &&
(!@primsub));
+ if ($title eq 'Personal') {
+ $title = &mt($title);
+ }
} else {
$title = &mt($title);
}
if (@primsub > 0) {
- $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} .= ''.$title.' ';
+ $menu{$position} .= ($listclass?'':' ').
+ ''.$title.' ';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -382,13 +391,22 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem,$ltitarget);
+ $menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$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,$ltitarget,$listclass,$linkattr);
} else {
- $menu{$position} .= prep_menuitem($menuitem,$ltitarget);
+ $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr);
}
}
my @output = ('','');
@@ -427,7 +445,7 @@ sub getauthor{
}
sub secondary_menu {
- my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref) = @_;
+ my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,$links_disabled) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -504,6 +522,12 @@ sub secondary_menu {
%menuopts = %{$menuref};
}
+ 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'}";
@@ -610,9 +634,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'}) {
@@ -656,7 +683,7 @@ sub secondary_menu {
}
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
- $menu .= &prep_menuitem(\@$menuitem,$ltitarget);
+ $menu .= &prep_menuitem(\@$menuitem,$ltitarget,$listclass,$linkattr);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -694,7 +721,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 '') {
@@ -709,7 +736,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;
@@ -719,7 +746,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 '';
}
@@ -784,8 +811,10 @@ sub build_submenu {
}
}
- $menu .= '';
- $menu .= '' . $title . ' ';
+ $menu .= ' ';
+ $menu .= '' . $title . ' ';
$menu .= ' ';
}
}
@@ -1027,6 +1056,13 @@ sub innerregister {
$currdir =~ s|[^/]+$||;
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
my $esc_currdir = &Apache::loncommon::escape_single($currdir);
+ my $pubfile = "/res/$udom/$uname/$thisdisfn";
+ my $candelete = 1;
+ if (-e $londocroot.$pubfile) {
+ unless (&Apache::lonnet::metadata($pubfile,'obsolete')) {
+ undef($candelete);
+ }
+ }
#
# Probably should be in mydesk.tab
#
@@ -1034,7 +1070,18 @@ sub innerregister {
s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
+s&7&3©.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource
+ENDMENUITEMS
+#
+# Rename and Delete only available if obsolete or unpublished
+#
+ if ($candelete) {
+ $menuitems .= (<
+
ENDCONSTSPACEFORM
}