--- loncom/interface/lonmenu.pm 2021/01/02 21:07:36 1.504 +++ loncom/interface/lonmenu.pm 2021/06/07 03:32:02 1.507 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.504 2021/01/02 21:07:36 raeburn Exp $ +# $Id: lonmenu.pm,v 1.507 2021/06/07 03:32:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -247,8 +247,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) = @_; - my (%menu,%ltiexc); + my ($crstype,$ltimenu,$menucoll,$menuref) = @_; + my (%menu,%ltiexc,%menuopts); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition, position) my $public; @@ -277,6 +277,9 @@ sub primary_menu { } } } + if (($menucoll) && (ref($menuref) eq 'HASH')) { + %menuopts = %{$menuref}; + } foreach my $menuitem (@primary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; # @@ -312,6 +315,9 @@ sub primary_menu { if ($position eq '') { $position = 'right'; } + if ($env{'request.course.id'} && $menucoll) { + next if (($menuitem->[6]) && (!$menuopts{$menuitem->[6]})); + } if (defined($primary_submenu{$title})) { my ($link,$target); if ($menuitem->[0] ne '') { @@ -331,10 +337,14 @@ 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' && $env{'user.name'} && $env{'user.domain'} ) { - unless ($ltiexc{'fullname'}) { + unless (($ltiexc{'fullname'}) || + (($env{'request.course.id'}) && ($menucoll) && (!$menuopts{'name'}))) { $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); } } else { @@ -400,7 +410,7 @@ sub getauthor{ } sub secondary_menu { - my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_; + my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref) = @_; my $menu; my $crstype = &Apache::loncommon::course_type(); @@ -424,7 +434,8 @@ sub secondary_menu { my $canplc = &Apache::lonnet::allowed('plc', $crs_sec); my $author = &getauthor(); - my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc); + my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools, + $lti,$ltimapres,%ltiexc,%menuopts); $grouptools = 0; if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -472,6 +483,9 @@ sub secondary_menu { } } } + if (($menucoll) && (ref($menuref) eq 'HASH')) { + %menuopts = %{$menuref}; + } my ($canmodifycoauthor); if ($env{'request.role'} eq "au./$env{'user.domain'}/") { @@ -534,11 +548,16 @@ sub secondary_menu { && $ltiexc{'logout'}; my $title = $menuitem->[3]; + if ($env{'request.course.id'} && $menucoll) { + unless ($$menuitem[5] eq 'roles') { + next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})); + } + } if (defined($secondary_submenu{$title})) { my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; - unless ($ltitarget eq 'iframe') { + unless ($ltitarget eq 'iframe') { $target = '_top'; } } else { @@ -568,25 +587,29 @@ sub secondary_menu { push(@scndsub,$item); } } - if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { + if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'}) { unless ($ltiexc{'fullname'}) { $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); } } if (@scndsub > 0) { - $menu .= &create_submenu($link,$target,$title,\@scndsub,1); + $menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1); } elsif ($link ne '#') { $menu .= '