--- loncom/interface/lonnavmaps.pm 2018/04/14 17:52:43 1.542
+++ loncom/interface/lonnavmaps.pm 2021/04/29 17:45:22 1.551
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.542 2018/04/14 17:52:43 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.551 2021/04/29 17:45:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -592,7 +592,11 @@ sub getLinkForResource {
my $anchor;
if ($res->is_page()) {
foreach my $item (@$stack) { if (defined($item)) { $anchor = $item; } }
- $anchor=&escape($anchor->shown_symb());
+ if ($anchor->encrypted() && !&advancedUser()) {
+ $anchor='LC_'.$anchor->id();
+ } else {
+ $anchor=&escape($anchor->shown_symb());
+ }
return ($res->link(),$res->shown_symb(),$anchor);
}
# in case folder was skipped over as "only sequence"
@@ -963,32 +967,32 @@ sub render_resource {
$newBranchText = "";
}
- # links to open and close the folder
-
my $whitespace = $location.'/whitespace_21.gif';
- my $linkopen = "
";
- my $nomodal;
- if (($params->{'modalLink'}) && (!$resource->is_sequence())) {
- if ($link =~m{^(?:|/adm/wrapper)/ext/([^#]+)}) {
- my $exturl = $1;
- if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
+ my ($nomodal,$linkopen,$linkclose);
+ unless ($resource->is_map() || $params->{'resource_nolink'}) {
+ $linkopen = "
";
+ $linkclose = "";
+ if (($params->{'modalLink'}) && (!$resource->is_sequence())) {
+ if ($link =~m{^(?:|/adm/wrapper)/ext/([^#]+)}) {
+ my $exturl = $1;
+ if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
+ $nomodal = 1;
+ }
+ } elsif (($link eq "/public/$LONCAPA::match_domain/$LONCAPA::match_courseid/syllabus") &&
+ ($env{'request.course.id'}) && ($ENV{'SERVER_PORT'} == 443) &&
+ ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
$nomodal = 1;
}
- } elsif (($link eq "/public/$LONCAPA::match_domain/$LONCAPA::match_courseid/syllabus") &&
- ($env{'request.course.id'}) && ($ENV{'SERVER_PORT'} == 443) &&
- ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- $nomodal = 1;
- }
- my $esclink = &js_escape($link);
- if ($nomodal) {
- $linkopen .= "";
+ my $esclink = &js_escape($link);
+ if ($nomodal) {
+ $linkopen .= "";
+ } else {
+ $linkopen .= "";
+ }
} else {
- $linkopen .= "";
+ $linkopen .= "";
}
- } else {
- $linkopen .= "";
}
- my $linkclose = "";
# Default icon: unknown page
my $icon = "
";
@@ -1036,13 +1040,14 @@ sub render_resource {
'&jump=' .
&escape($resource->symb()) .
"&folderManip=1\">";
-
+ $linkclose = '';
} else {
# Don't allow users to manipulate folder
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
$icon = "
"."
";
if ($params->{'caller'} eq 'sequence') {
$linkopen = "";
+ $linkclose = '';
} else {
$linkopen = "";
$linkclose = "";
@@ -1061,10 +1066,15 @@ sub render_resource {
}
if ($params->{'mapHidden'} || $resource->randomout()) {
$nonLinkedText .= ' ('.&mt('hidden').') ';
+ } elsif ($params->{'mapUnlisted'}) {
+ $nonLinkedText .= ' ('.&mt('unlisted').') ';
}
} else {
if ($resource->randomout()) {
$nonLinkedText .= ' ('.&mt('hidden').') ';
+ } elsif (($resource->deeplink($params->{caller}) eq 'absent') ||
+ ($resource->deeplink($params->{caller}) eq 'grades')) {
+ $nonLinkedText .= ' ('.&mt('unlisted').') ';
}
}
if (!$resource->condval()) {
@@ -1388,7 +1398,9 @@ sub render {
# Without renaming the filterfunc, the server seems to go into
# an infinite loop
my $oldFilterFunc = $filterFunc;
- $filterFunc = sub { my $res = shift; return !$res->randomout() &&
+ $filterFunc = sub { my $res = shift; return !$res->randomout() &&
+ ($res->deeplink($args->{'caller'}) ne 'absent') &&
+ ($res->deeplink($args->{'caller'}) ne 'grades') &&
&$oldFilterFunc($res);};
}
@@ -1482,10 +1494,13 @@ sub render {
if ($args->{'iterator_map'}) {
my $map = $args->{'iterator_map'};
$map = $navmap->getResourceByUrl($map);
- my $firstResource = $map->map_start();
- my $finishResource = $map->map_finish();
-
- $args->{'iterator'} = $it = $navmap->getIterator($firstResource, $finishResource, $filterHash, $condition);
+ if (ref($map)) {
+ my $firstResource = $map->map_start();
+ my $finishResource = $map->map_finish();
+ $args->{'iterator'} = $it = $navmap->getIterator($firstResource, $finishResource, $filterHash, $condition);
+ } else {
+ return;
+ }
} else {
$args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition,undef,$args->{'include_top_level_map'});
}
@@ -1805,6 +1820,7 @@ END
# If this is an empty sequence and we're filtering them, continue on
$args->{'mapHidden'} = 0;
+ $args->{'mapUnlisted'} = 0;
if (($curRes->is_map()) && (!$curRes->{DATA}->{HAS_VISIBLE_CHILDREN})) {
if ($args->{'suppressEmptySequences'}) {
next;
@@ -1817,6 +1833,15 @@ END
} else {
next;
}
+ } else {
+ my $deeplink = $navmap->get_mapparam(undef,$mapname,"0.deeplink");
+ if ($deeplink =~ /^(absent|grades),/) {
+ if ($userCanSeeHidden) {
+ $args->{'mapUnlisted'} = 1;
+ } else {
+ next;
+ }
+ }
}
}
}
@@ -1879,8 +1904,17 @@ END
$args->{'condensed'} = 1;
}
}
- }
-
+ }
+ # If deep-link parameter is set (and is not set to full) suppress link
+ # unless privileged user, or calling context is sequence, and parameter
+ # set at map level
+ if ((!$curRes->deeplink($args->{'caller'})) ||
+ ($curRes->deeplink($args->{'caller'}) =~ /^full,/) || &advancedUser()) {
+ $args->{'resource_nolink'} = 0;
+ } else {
+ $args->{'resource_nolink'} = 1;
+ }
+
# If the multipart problem was condensed, "forget" it was multipart
if (scalar(@parts) == 1) {
$args->{'multipart'} = 0;
@@ -1906,14 +1940,20 @@ END
if ($env{'request.course.id'}) {
if (($is_ssl) && ($src =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- if ($hostname ne '') {
- $src = 'http://'.$hostname.$src;
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
+ if ($hostname ne '') {
+ $src = 'http://'.$hostname.$src;
+ }
+ $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1';
+ $srcHasQuestion = 1;
}
- $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1';
- $srcHasQuestion = 1;
} elsif (($is_ssl) && ($src =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) {
- if ($hostname ne '') {
- $src = 'http://'.$hostname.$src;
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
+ if ($hostname ne '') {
+ $src = 'http://'.$hostname.$src;
+ }
+ $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1';
+ $srcHasQuestion = 1;
}
}
}
@@ -1952,7 +1992,7 @@ END
$currentJumpDelta) {
# Jam the anchor after the