--- loncom/interface/lonmenu.pm 2022/05/24 16:23:03 1.516
+++ loncom/interface/lonmenu.pm 2022/09/13 12:22:14 1.527
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.516 2022/05/24 16:23:03 raeburn Exp $
+# $Id: lonmenu.pm,v 1.527 2022/09/13 12:22:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,7 +99,7 @@ It gets filled in the BEGIN block of thi
=over
-=item prep_menuitems(\@menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr)
+=item prep_menuitems(\@menuitem,$target,$listclass,$linkattr)
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
secondary_menu().
@@ -220,9 +220,9 @@ use vars qw(@desklines %category_names %
my @inlineremote;
sub prep_menuitem {
- my ($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr) = @_;
+ my ($menuitem,$target,$listclass,$linkattr) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
- my $link;
+ my ($link,$targetattr);
if ($$menuitem[1]) { # graphical Link
$link = "':'
').'$link|;
+ . qq| href="$$menuitem[0]"$targetattr $linkattr>$link|;
}
# primary_menu() evaluates @primary_menu and returns a two item array,
@@ -249,7 +246,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,$links_disabled) = @_;
+ my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target) = @_;
my (%menu,%ltiexc,%menuopts);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
@@ -267,10 +264,9 @@ sub primary_menu {
my %roles_in_env;
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
}
- my ($lti,$ltitarget,$deeplinktarget);
+ my $lti;
if ($env{'request.lti.login'}) {
$lti = 1;
- $ltitarget = $env{'request.lti.target'};
if (ref($ltimenu) eq 'HASH') {
foreach my $item ('fullname','logout') {
unless ($ltimenu->{$item}) {
@@ -279,8 +275,26 @@ sub primary_menu {
}
}
}
- if ($env{'request.deeplink.login'}) {
- $deeplinktarget = $env{'request.deeplink.target'};
+ my ($listclass,$linkattr,$target);
+ if ($links_disabled) {
+ $listclass = 'LCisDisabled';
+ $linkattr = 'aria-disabled="true"';
+ }
+ if ($links_target ne '') {
+ $target = $links_target;
+ } else {
+ my ($ltitarget,$deeplinktarget);
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
+ if ($env{'request.deeplink.login'}) {
+ $deeplinktarget = $env{'request.deeplink.target'};
+ }
+ if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
+ $target = '_self';
+ } else {
+ $target = '_top';
+ }
}
if (($menucoll) && (ref($menuref) eq 'HASH')) {
%menuopts = %{$menuref};
@@ -337,18 +351,10 @@ sub primary_menu {
}
}
}
- my ($listclass,$linkattr);
- if ($links_disabled) {
- $listclass = 'LCisDisabled';
- $linkattr = 'aria-disabled="true"';
- }
if (defined($primary_submenu{$title})) {
- my ($link,$target);
+ my $link;
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
- unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
- $target = '_top';
- }
} else {
$link = '#';
}
@@ -396,7 +402,7 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr);
+ $menu{$position} .= &prep_menuitem($menuitem,$target,$listclass,$linkattr);
}
} else {
$menu{$position} .= ($listclass?'':'').
@@ -409,9 +415,9 @@ sub primary_menu {
$$menuitem[0] = '/adm/login';
}
}
- $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr);
+ $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
} else {
- $menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr);
+ $menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr);
}
}
my @output = ('','');
@@ -450,7 +456,8 @@ sub getauthor{
}
sub secondary_menu {
- my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,$links_disabled) = @_;
+ my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,
+ $links_disabled,$links_target) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -527,7 +534,7 @@ sub secondary_menu {
%menuopts = %{$menuref};
}
- my ($listclass,$linkattr);
+ my ($listclass,$linkattr,$target);
if ($links_disabled) {
$listclass = 'LCisDisabled';
$linkattr = 'aria-disabled="true"';
@@ -542,12 +549,22 @@ sub secondary_menu {
}
}
- my ($roleswitcher_js,$roleswitcher_form,$ltitarget,$deeplinktarget);
- if ($env{'request.lti.login'}) {
- $ltitarget = $env{'request.lti.target'};
- }
- if ($env{'request.deeplink.login'}) {
- $deeplinktarget = $env{'request.deeplink.target'};
+ my ($roleswitcher_js,$roleswitcher_form);
+ if ($links_target ne '') {
+ $target = $links_target;
+ } else {
+ my ($ltitarget,$deeplinktarget);
+ if ($env{'request.lti.login'}) {
+ $ltitarget = $env{'request.lti.target'};
+ }
+ if ($env{'request.deeplink.login'}) {
+ $deeplinktarget = $env{'request.deeplink.target'};
+ }
+ if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
+ $target = '_self';
+ } else {
+ $target = '_top';
+ }
}
foreach my $menuitem (@secondary_menu) {
@@ -603,12 +620,9 @@ sub secondary_menu {
}
}
if (defined($secondary_submenu{$title})) {
- my ($link,$target);
+ my $link;
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
- unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) {
- $target = '_top';
- }
} else {
$link = '#';
}
@@ -657,7 +671,7 @@ sub secondary_menu {
&roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost
+ $httphost,$target,$menucoll,$menuref
);
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
next unless ($has_opa_priv);
@@ -691,7 +705,7 @@ sub secondary_menu {
}
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
- $menu .= &prep_menuitem(\@$menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr);
+ $menu .= &prep_menuitem(\@$menuitem,$target,$listclass,$linkattr);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -731,12 +745,12 @@ sub secondary_menu {
sub create_submenu {
my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_;
return unless (ref($submenu) eq 'ARRAY');
- my $disptarget;
- if ($target ne '') {
- $disptarget = ' target="'.$target.'"';
+ my $targetattr;
+ if (($target ne '') && ($link ne '#')) {
+ $targetattr = ' target="'.$target.'"';
}
my $menu = ''.
- ''.
+ ''.
''.$title.
''.
' ▼'.
@@ -813,16 +827,17 @@ sub build_submenu {
}
$href =~ s/\[returnurl\]/$returnurl/;
}
+ my $targetattr;
unless (($href eq '') || ($href =~ /^\#/)) {
- if ($target eq '_top') {
- $target = ' target="_top"';
+ if ($target ne '') {
+ $targetattr = ' target="'.$target.'"';
}
}
$menu .= '';
- $menu .= '' . $title . '';
+ $menu .= '' . $title . '';
$menu .= '';
}
}
@@ -831,7 +846,8 @@ sub build_submenu {
}
sub innerregister {
- my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_;
+ my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,
+ $ltiscope,$ltiuri,$showncrumbsref) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
my $is_const_dir = 0;
@@ -872,10 +888,7 @@ sub innerregister {
}
}
}
- unless (($forcereg) &&
- ($env{'request.noversionuri'} eq '/adm/navmaps') &&
- ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
- (($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
+ unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) ||
($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
@crumbs = ({text => $crstype.' Contents',
href => "Javascript:gopost('/adm/navmaps','')"});
@@ -926,14 +939,17 @@ sub innerregister {
if ($env{'form.folderpath'}) {
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
{text => "Supplemental $crstype Content",
href => "javascript:gopost('/adm/supplemental','')"});
$title = &mt('View Resource');
($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
+ }
+ if (ref($showncrumbsref)) {
+ $$showncrumbsref = 1;
}
return $trail;
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
@@ -942,7 +958,10 @@ sub innerregister {
$forcereg,$group,undef,undef,1,$hostname);
$title = &mt('Syllabus File');
my ($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
+ if (ref($showncrumbsref)) {
+ $$showncrumbsref = 1;
+ }
return $trail;
}
unless ($env{'request.state'} eq 'construct') {
@@ -1249,10 +1268,13 @@ ENDMENUITEMS
}
}
}
- my $showprogress;
+ my ($showprogress,$linkprotout);
if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
$showprogress = &placement_progress();
}
+ if ($env{'request.deeplink.login'}) {
+ $linkprotout = &linkprot_exit();
+ }
my $addremote=0;
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
@@ -1278,6 +1300,9 @@ ENDMENUITEMS
if ($countdown) {
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
}
+ if ($linkprotout) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
+ }
if ($showprogress) {
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
}
@@ -1286,6 +1311,9 @@ ENDMENUITEMS
if ($countdown) {
unshift(@tools,$countdown);
}
+ if ($linkprotout) {
+ unshift(@tools,$linkprotout);
+ }
&Apache::lonhtmlcommon::add_breadcrumb_tool(
'tools',@tools);
@@ -1303,6 +1331,9 @@ ENDMENUITEMS
if ($showprogress) {
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
}
+ if ($linkprotout) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
+ }
}
my ($topic_help,$topic_help_text);
if ($is_const_dir == 2) {
@@ -1314,6 +1345,9 @@ ENDMENUITEMS
$topic_help_text = 'About WebDAV access';
}
}
+ if (ref($showncrumbsref)) {
+ $$showncrumbsref = 1;
+ }
return &Apache::lonhtmlcommon::scripttag('', 'start')
. &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text)
. &Apache::lonhtmlcommon::scripttag('', 'end');
@@ -1337,8 +1371,12 @@ sub get_editbutton {
if ($env{'form.folderpath'}) {
$suppanchor = $env{'form.anchor'};
}
+ my $shownsymb;
+ if ($env{'request.symb'}) {
+ $shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'});
+ }
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
- $forceedit,$forcereg,$env{'request.symb'},
+ $forceedit,$forcereg,$env{'request.symb'},$shownsymb,
&escape($env{'form.folderpath'}),
&escape($env{'form.title'}),$hostname,
$env{'form.idx'},&escape($env{'form.suppurl'}),
@@ -1934,8 +1972,17 @@ sub check_for_rcrs {
if (!$showreqcrs) {
foreach my $type (@reqtypes) {
if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
- $showreqcrs = 1;
- last;
+ my @domains = split(',',$env{'environment.reqcrsotherdom.'.$type});
+ foreach my $entry (@domains) {
+ my ($extdom,$extopt) = split(':',$entry);
+ if (&Apache::lonnet::will_trust('reqcrs',$env{'user.domain'},$extdom)) {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ if ($showreqcrs) {
+ last;
+ }
}
}
}
@@ -2368,7 +2415,8 @@ function golist(url) {
currentSymb= null;
var lcHostname = setLCHost();
var ltitarget = '$ltitarget';
- if (ltitarget == 'iframe') {
+ var deeplinktarget = '$deeplinktarget';
+ if ((ltitarget == 'iframe') || (deeplinktarget == '_self')) {
document.location.href=lcHostname+url;
} else {
top.location.href=lcHostname+url;
@@ -2480,11 +2528,17 @@ ENDSERVERFORM
}
sub constspaceform {
+ my ($frameset) = @_;
my ($target,$printtarget);
- unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
- (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
- $target = ' target="_top"';
+ if ($frameset) {
+ $target = ' target="_parent"';
$printtarget = ' target="_parent"';
+ } else {
+ unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
+ (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
+ $target = ' target="_top"';
+ $printtarget = ' target="_top"';
+ }
}
return(<
@@ -2519,7 +2573,7 @@ sub hidden_button_check {
}
sub roles_selector {
- my ($cdom,$cnum,$httphost) = @_;
+ my ($cdom,$cnum,$httphost,$target,$menucoll,$menuref) = @_;
my $crstype = &Apache::loncommon::course_type();
my $now = time;
my (%courseroles,%seccount,%courseprivs,%roledesc);
@@ -2625,10 +2679,15 @@ sub roles_selector {
}
}
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
+ my $targetattr;
+ if ($target ne '') {
+ $targetattr = ' target="'.$target.'"';
+ }
my @submenu;
- $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref);
+ $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,
+ \%roledesc,$privref,$menucoll,$menuref);
$form =
- '
+
+
+
$lt{'okdone'} $lt{'cancel'}
+
+
+
+
+END
+ }
+ }
+ }
+ }
+ }
+ }
+ return;
+}
+
# ================================================================ Main Program
BEGIN {