--- loncom/interface/lonnavmaps.pm 2016/07/18 19:28:57 1.522 +++ loncom/interface/lonnavmaps.pm 2017/02/18 23:39:16 1.527 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.522 2016/07/18 19:28:57 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.527 2017/02/18 23:39:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -995,7 +995,8 @@ sub render_resource { $linkopen = ""; $linkclose = ""; } - if ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && + if (((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) || + (&Apache::lonnet::allowed('cev',$env{'request.course.id'}))) && ($resource->symb=~/\_\_\_[^\_]+\_\_\_uploaded/)) { if (!$params->{'map_no_edit_link'}) { my $icon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png'; @@ -1540,7 +1541,8 @@ END $result.=''; } if (($args->{'caller'} eq 'navmapsdisplay') && - (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) || + (&Apache::lonnet::allowed('cev',$env{'request.course.id'})))) { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; if ($env{'course.'.$env{'request.course.id'}.'.url'} eq @@ -1682,6 +1684,18 @@ 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); + if ($ENV{'SERVER_PORT'} == 443) { + $is_ssl = 1; + } + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } while (1) { if ($args->{'sort'}) { @@ -1815,8 +1829,15 @@ END $stack=$it->getStack(); } ($src,$symb,$anchor)=getLinkForResource($stack); + my $srcHasQuestion = $src =~ /\?/; + if ($env{'request.course.id'}) { + if (($src =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) && ($is_ssl) && + ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { + $src .= ($srcHasQuestion? '&' : '?') . 'usehttp=1'; + $srcHasQuestion = 1; + } + } if (defined($anchor)) { $anchor='#'.$anchor; } - my $srcHasQuestion = $src =~ /\?/; $args->{"resourceLink"} = $src. ($srcHasQuestion?'&':'?') . 'symb=' . &escape($symb).$anchor; @@ -2686,7 +2707,13 @@ sub parmval_real { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what; - last if (defined($$useropt{$norecursechk})); + if (defined($$useropt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return [$$useropt{$norecursechk},'map']; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; if (defined($$useropt{$recursechk})) { return [$$useropt{$recursechk},'map']; } } @@ -2704,7 +2731,13 @@ sub parmval_real { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return [$$courseopt{$norecursechk},'map']; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; } } @@ -2721,7 +2754,13 @@ sub parmval_real { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return [$$courseopt{$norecursechk},'map']; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; } } @@ -2755,7 +2794,13 @@ sub parmval_real { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return [$$courseopt{$norecursechk},'map']; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; @@ -2894,7 +2939,13 @@ sub get_mapparam { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what; - last if (defined($$useropt{$norecursechk})); + if (defined($$useropt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return $$useropt{$norecursechk}; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; if (defined($$useropt{$recursechk})) { return $$useropt{$recursechk}; @@ -2919,7 +2970,13 @@ sub get_mapparam { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return $$courseopt{$norecursechk}; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return $$courseopt{$recursechk}; @@ -2943,7 +3000,13 @@ sub get_mapparam { } foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return $$courseopt{$norecursechk}; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return $$courseopt{$recursechk}; @@ -2974,7 +3037,13 @@ sub get_mapparam { if (@recurseup) { foreach my $item (@recurseup) { my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what; - last if (defined($$courseopt{$norecursechk})); + if (defined($$courseopt{$norecursechk})) { + if ($what =~ /\.(encrypturl|hiddenresource)$/) { + return $$courseopt{$norecursechk}; + } else { + last; + } + } my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; if (defined($$courseopt{$recursechk})) { return $$courseopt{$recursechk}; @@ -4152,6 +4221,7 @@ sub enclosing_map_src { } sub symb { my $self=shift; + if (defined $self->{SYMB}) { return $self->{SYMB}; } (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/; my $symbSrc = &Apache::lonnet::declutter($self->src()); my $symb = &Apache::lonnet::declutter($self->navHash('map_id_'.$first)) @@ -4786,8 +4856,14 @@ sub getReturnHash { my $self = shift; if (!defined($self->{RETURN_HASH})) { - my %tmpHash = &Apache::lonnet::restore($self->{SYMB},undef,$self->{DOMAIN},$self->{USERNAME}); - $self->{RETURN_HASH} = \%tmpHash; + #my %tmpHash = &Apache::lonnet::restore($self->{SYMB},undef,$self->{DOMAIN},$self->{USERNAME}); + #$self->{RETURN_HASH} = \%tmpHash; + # When info is retrieved for several resources (as when rendering a directory), + # it is much faster to use the user profile dump and avoid repeated lonnet requests + # (especially since lonnet::currentdump is using Lond directly whenever possible, + # and lonnet::restore is not at this point). + $self->{NAV_MAP}->get_user_data(); + $self->{RETURN_HASH} = $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}}; } }