--- rat/lonpageflip.pm 2016/05/30 02:52:42 1.91 +++ rat/lonpageflip.pm 2017/02/18 23:39:24 1.92 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.91 2016/05/30 02:52:42 raeburn Exp $ +# $Id: lonpageflip.pm,v 1.92 2017/02/18 23:39:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -245,6 +245,7 @@ sub first_accessible_resource { my ($newmapid,$newresid)=split(/\./,$newrid); my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid}); $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb }); + &check_for_syllabus(\$furl); if ($hash{'encrypted_'.$newrid}) { $furl=&Apache::lonenc::encrypted($furl); } @@ -279,6 +280,20 @@ sub first_answerable_ressymb { } } +sub check_for_syllabus { + my ($srcref) = @_; + return unless (ref($srcref) eq 'SCALAR'); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if (($$srcref =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) && + ($ENV{'SERVER_PORT'} == 443) && + ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { + $$srcref .= (($$srcref =~/\?/)? '&':'?') . 'usehttp=1'; + } + } +} + # ================================================================ Main Handler sub handler { @@ -379,7 +394,12 @@ sub handler { $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id; $newloc=$hash{'src_'.$id}; if ($newloc) { - if ($hash{'encrypted_'.$id}) { $newloc=&Apache::lonenc::encrypted($newloc); } + &check_for_syllabus(\$newloc); + if ($hash{'encrypted_'.$id}) { + $newloc=&Apache::lonenc::encrypted($newloc); + } elsif ($newloc =~ m{^(/adm/wrapper/ext/[^\#]+)\#([^\#]+)$}) { + $newloc = $1.&escape('#').$2; + } } else { $newloc='/adm/navmaps'; } @@ -494,6 +514,7 @@ sub handler { # ------------------------------------- Check for and display critical messages my ($redirect, $url) = &Apache::loncommon::critical_redirect(300); unless ($redirect) { + &check_for_syllabus(\$redirecturl); $url=&Apache::lonnet::absolute_url().$redirecturl; my $addanchor; if (($anchor ne '') && (!$enc || $env{'request.role.adv'})) { @@ -543,9 +564,11 @@ $lt{'pick'}: $lt{'titleheader'}$lt{'type'} ENDSTART foreach my $id (@possibilities) { + my $src = $multichoicehash{'src_'.$id}; + &check_for_syllabus(\$src); $r->print( ''.