--- loncom/interface/lonnavmaps.pm 2018/04/14 17:52:43 1.542
+++ loncom/interface/lonnavmaps.pm 2019/01/16 20:23:37 1.546
@@ -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.546 2019/01/16 20:23:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -963,32 +963,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 +1036,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 +1062,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 +1394,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 +1490,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 +1816,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 +1829,15 @@ END
} else {
next;
}
+ } else {
+ my $deeplink = $navmap->get_mapparam(undef,$mapname,"0.deeplink");
+ if (($deeplink eq 'absent') || ($deeplink eq 'grades')) {
+ if ($userCanSeeHidden) {
+ $args->{'mapUnlisted'} = 1;
+ } else {
+ next;
+ }
+ }
}
}
}
@@ -1879,8 +1900,17 @@ END
$args->{'condensed'} = 1;
}
}
- }
-
+ }
+ # If deep-link parameter is set (and is not set to full) suppress link
+ # unless priviliged user, or calling context is sequence, and parameter
+ # set at map level
+ if ((!$curRes->deeplink($args->{'caller'})) ||
+ ($curRes->deeplink($args->{'caller'}) eq '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 +1936,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()) {
+ 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()) {
+ if ($hostname ne '') {
+ $src = 'http://'.$hostname.$src;
+ }
+ $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1';
+ $srcHasQuestion = 1;
}
}
}
@@ -2958,7 +2994,7 @@ sub recursed_crumbs {
my $pc = $map->map_pc();
next if ((!$pc) || ($pc == 1));
push(@links,$map);
- push(@revmapinfo,{'href' => $map->link().'?navmap=1','text' => $map->title(),'no_mt' => 1,});
+ push(@revmapinfo,{'href' => $env{'request.use_absolute'}.$map->link().'?navmap=1','text' => $map->title(),'no_mt' => 1,});
$totallength += length($map->title());
}
my $numlinks = scalar(@links);
@@ -2973,7 +3009,7 @@ sub recursed_crumbs {
foreach my $map (@links) {
my $showntitle = &truncate_crumb_text($map->title(),$avg);
if ($showntitle ne '') {
- push(@revmapinfo,{'href' => $map->link().'?navmap=1','text' => $showntitle,'no_mt' => 1,});
+ push(@revmapinfo,{'href' => $env{'request.use_absolute'}.$map->link().'?navmap=1','text' => $showntitle,'no_mt' => 1,});
}
}
}
@@ -4692,7 +4728,6 @@ sub is_task {
sub is_empty_sequence {
my $self=shift;
- my $src = $self->src();
return !$self->is_page() && $self->navHash("is_map_", 1) && !$self->navHash("map_type_" . $self->map_pc());
}
@@ -5112,6 +5147,17 @@ sub slot_control {
my $available = $self->parmval("available", $part);
return ($useslots,$availablestudent,$available);
}
+sub deeplink {
+ my ($self,$caller) = @_;
+ if ($caller eq 'sequence') {
+ my @deeplink = $self->parmval("deeplink");
+ if ($deeplink[1] eq 'resource') {
+ return $deeplink[0];
+ }
+ } else {
+ return $self->parmval("deeplink");
+ }
+}
# Multiple things need this
sub getReturnHash {