--- loncom/interface/lonnavmaps.pm 2019/02/07 00:49:53 1.509.2.10 +++ loncom/interface/lonnavmaps.pm 2019/07/27 16:44:31 1.509.2.11 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.509.2.10 2019/02/07 00:49:53 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.509.2.11 2019/07/27 16:44:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees @@ -1726,6 +1726,23 @@ END undef($args->{'sort'}); } + # Determine if page will be served with https in case + # it contains a syllabus which uses an external URL + # which points at an http site. + + my ($is_ssl,$cdom,$cnum,$hostname); + if ($ENV{'SERVER_PORT'} == 443) { + $is_ssl = 1; + if ($r) { + $hostname = $r->hostname(); + } else { + $hostname = $ENV{'SERVER_NAME'}; + } + } + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } my $inhibitmenu; if ($args->{'modalLink'}) { @@ -1864,7 +1881,27 @@ END $stack=$it->getStack(); } ($src,$symb,$anchor)=getLinkForResource($stack); - my $srcHasQuestion = $src =~ /\?/; + my $srcHasQuestion = $src =~ /\?/; + 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://})) { + unless (&Apache::lonnet::uses_sts()) { + if ($hostname ne '') { + $src = 'http://'.$hostname.$src; + } + $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1'; + $srcHasQuestion = 1; + } + } elsif (($is_ssl) && ($src =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) { + unless (&Apache::lonnet::uses_sts()) { + if ($hostname ne '') { + $src = 'http://'.$hostname.$src; + } + $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1'; + $srcHasQuestion = 1; + } + } + } if (defined($anchor)) { $anchor='#'.$anchor; } if (($args->{'caller'} eq 'sequence') && ($curRes->is_map())) { $args->{"resourceLink"} = $src.($srcHasQuestion?'&':'?') .'navmap=1'; @@ -2825,7 +2862,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); @@ -2840,7 +2877,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,}); } } }