[LON-CAPA-cvs] cvs: rat / lonpageflip.pm loncom/interface coursecatalog.pm londocs.pm lonhtmlcommon.pm lonmenu.pm lonnavmaps.pm lonsyllabus.pm loncom/rewrites loncapa_rewrite_off.conf loncapa_rewrite_on.conf

raeburn raeburn at source.lon-capa.org
Sat Feb 18 18:39:24 EST 2017


raeburn		Sat Feb 18 23:39:24 2017 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm londocs.pm lonhtmlcommon.pm 
                     	lonmenu.pm lonnavmaps.pm lonsyllabus.pm 
    /loncom/rewrites	loncapa_rewrite_on.conf loncapa_rewrite_off.conf 
    /rat	lonpageflip.pm 
  Log:
  - Append ?usehttp=1 to link to syllabus where LON-CAPA syllabus is configured 
    to use external http:// URL, but LON-CAPA server uses https:// to avoid
    mixed active content issue (see also bug 6662).
  - Preview of external http:// URL displayed in separate pop-up window  
    instead of in modal window on https:// server.
  
  
-------------- next part --------------
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.90 loncom/interface/coursecatalog.pm:1.91
--- loncom/interface/coursecatalog.pm:1.90	Wed Oct  5 13:36:53 2016
+++ loncom/interface/coursecatalog.pm	Sat Feb 18 23:39:15 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.90 2016/10/05 13:36:53 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.91 2017/02/18 23:39:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -176,8 +176,12 @@
                                       $courseinfo{$codedom.'_'.$cnum}{$item});
                             if ($item eq 'title') {
                                 if ($courseinfo{$codedom.'_'.$cnum}{'showsyllabus'}) {
+                                    my $usehttp = 0;
+                                    if (($ENV{'SERVER_PORT'} == 443) && ($courseinfo{$codedom.'_'.$cnum}{'extsyllplain'})) {
+                                        $usehttp = 1;
+                                    }
                                     $r->print(' <font size="-2">'.
-                                              '<a href="javascript:ToSyllabus('."'$codedom','$cnum'".')">'.
+                                              '<a href="javascript:ToSyllabus('."'$codedom','$cnum','$usehttp'".')">'.
                                               &mt('Syllabus').'</a></font>');
                                 }
                             }
@@ -414,7 +418,7 @@
 sub courselink_javascript {
     return <<"END";
 
-function ToSyllabus(cdom,cnum) {
+function ToSyllabus(cdom,cnum,usehttp) {
     if (cdom == '' || cdom == null) {
         return;
     }
@@ -422,6 +426,9 @@
         return;
     }
     document.linklaunch.action = "/public/"+cdom+"/"+cnum+"/syllabus";
+    if (usehttp == 1) {
+        document.linklaunch.action += '?usehttp=1';
+    }
     document.linklaunch.submit();
 }
 
@@ -1275,7 +1282,7 @@
         $cleandesc=~s/'/\\'/g;
         $cleandesc =~ s/^\s+//;
         my ($cdom,$cnum)=split(/\_/,$course);
-        my ($instcode,$singleowner,$ttype,$selfenroll_types,
+        my ($instcode,$singleowner,$ttype,$selfenroll_types,$extsyllplain,
             $selfenroll_start,$selfenroll_end, at owners,%ownernames,$categories);
         if (ref($courses->{$course}) eq 'HASH') {
             $descr = $courses->{$course}{'description'};
@@ -1286,6 +1293,7 @@
             $selfenroll_start = $courses->{$course}{'selfenroll_start_date'};
             $selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
             $categories = $courses->{$course}{'categories'};
+            $extsyllplain = $courses->{$course}{'extsyllplain'};
             push(@owners,$singleowner);
             if ($courses->{$course}{'co-owners'} ne '') {
                 foreach my $item (split(/,/,$courses->{$course}{'co-owners'})) {
@@ -1329,6 +1337,7 @@
         $courseinfo{$course}{'selfenroll_start'} = $selfenroll_start;
         $courseinfo{$course}{'selfenroll_end'} = $selfenroll_end;
         $courseinfo{$course}{'categories'} = $categories;
+        $courseinfo{$course}{'extsyllplain'} = $extsyllplain;
 
         my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
         my @classids;
@@ -1513,7 +1522,8 @@
 sub courseinfo_row {
     my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems,$numbers,$canviewall) = @_;
     my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,
-        $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories);
+        $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories,
+        $extsyllplain);
     if (ref($info) eq 'HASH') {
         $cdom = $info->{'cdom'};
         $cnum = $info->{'cnum'};
@@ -1527,6 +1537,7 @@
         $counts = $info->{'counts'};
         $autoenrollment = $info->{'autoenrollment'};
         $showsyllabus = $info->{'showsyllabus'};
+        $extsyllplain = $info->{'extsyllplain'};
         $categories = $info->{'categories'};
     } else {
         $output = '<td colspan="8">'.&mt('No information available for [_1].',
@@ -1554,7 +1565,11 @@
                '<td>'.$xlist_items.'</td>'.
                '<td>'.$title.' <font size="-2">';
     if ($showsyllabus) {
-        $output .= '<a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a>';
+        my $usehttp = 0;
+        if (($ENV{'SERVER_PORT'} == 443) && ($extsyllplain)) {
+            $usehttp = 1;
+        }
+        $output .= '<a href="javascript:ToSyllabus('."'$cdom','$cnum','$usehttp'".')">'.&mt('Syllabus').'</a>';
     } else {
         $output .= ' ';
     }
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.620 loncom/interface/londocs.pm:1.621
--- loncom/interface/londocs.pm:1.620	Sat Feb 18 14:16:47 2017
+++ loncom/interface/londocs.pm	Sat Feb 18 23:39:15 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.620 2017/02/18 14:16:47 raeburn Exp $
+# $Id: londocs.pm,v 1.621 2017/02/18 23:39:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3970,7 +3970,7 @@
 	}
     }
 
-    my ($editlink,$extresform,$anchor,$hiddenres);
+    my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
     my $orig_url = $url;
     $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
     $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
@@ -3992,6 +3992,12 @@
 	        $url='/adm/wrapper'.$url;
 	    } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
 		$url='/adm/wrapper'.$url;
+            } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
+                if (($ENV{'SERVER_PORT'} == 443) &&
+                    ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                    $url .= '?usehttp=1';
+                    $nomodal = 1;
+                }
             }
             if (&Apache::lonnet::symbverify($symb,$url)) {
                 my $shownsymb = $symb;
@@ -4049,12 +4055,18 @@
                 $url='';
             }
 	}
-    } elsif ($supplementalflag) { 
+    } elsif ($supplementalflag) {
         if ($isexternal) {
             if ($url =~ /^([^#]+)#([^#]+)$/) {
                 $url = $1;
                 $anchor = $2;
             }
+        } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
+            if (($ENV{'SERVER_PORT'} == 443) &&
+                ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
+                $nomodal = 1;
+            }
         }
     }
     my ($rand_pick_text,$rand_order_text,$hiddenfolder);
@@ -4205,6 +4217,7 @@
         $reinit = &mt('(re-initialize course to access)');
     }
     $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
+    my $link;
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
     } elsif ($url) {
@@ -4215,9 +4228,15 @@
                $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
            }
        }
-       $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
-                                             (($anchor ne '')?$anchor:'')),
-                                             '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
+       $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
+                                               (($anchor ne '')?$anchor:''));
+       if ($nomodal) {
+           $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
+                  '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
+       } else {
+           $line.=&Apache::loncommon::modal_link($link,
+                                                 '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
+       }
     } else {
        $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
     }
@@ -4225,9 +4244,12 @@
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'">'.$title.'</a>';
     } elsif ($url) {
-       $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
-                                             (($anchor ne '')?$anchor:'')),
-                                             $title,600,500);
+       if ($nomodal) {
+           $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
+                  $title.'</a>';
+       } else {
+           $line.=&Apache::loncommon::modal_link($link,$title,600,500);
+       }
     } elsif (($hiddenfolder) || ($hiddenres)) {
        $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';
     } else {
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.379 loncom/interface/lonhtmlcommon.pm:1.380
--- loncom/interface/lonhtmlcommon.pm:1.379	Sat Jan 28 02:31:51 2017
+++ loncom/interface/lonhtmlcommon.pm	Sat Feb 18 23:39:16 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.379 2017/01/28 02:31:51 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.380 2017/02/18 23:39:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2201,11 +2201,11 @@
         my $foldername=shift(@folders);
         if ($folderpath) {$folderpath.='&';}
         $folderpath.=$folder.'&'.$foldername;
-        my $url;
+        my $url = $env{'request.use_absolute'};
         if ($allowed) {
-            $url = '/adm/coursedocs?folderpath=';
+            $url .= '/adm/coursedocs?folderpath=';
         } else {
-            $url = '/adm/supplemental?folderpath=';
+            $url .= '/adm/supplemental?folderpath=';
         }
         $url .= &escape($folderpath);
         my $name=&unescape($foldername);
@@ -3497,7 +3497,7 @@
 sub jump_to_editres {
     my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
         $title,$idx,$suppurl,$todocs,$suppanchor) = @_;
-    my ($jscall,$anchor);
+    my ($jscall,$anchor,$usehttp);
     if ($switchserver) {
         if ($home) {
             $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
@@ -3520,6 +3520,17 @@
             if ($cfile =~ m{^(/adm/wrapper/ext/[^#]+)#([^#]+)$}) {
                 $cfile = $1;
                 $anchor = $2;
+            } elsif ($cfile =~ m{^/public/($match_domain)/($match_courseid)/syllabus}) {
+                if ($ENV{'SERVER_PORT'} == 443) {
+                    my ($cdom,$cnum) = ($1,$2);
+                    if (($env{'request.course.id'}) &&
+                        ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum) &&
+                        ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom)) {
+                        if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
+                            $usehttp = 1;
+                        }
+                    }
+                }
             }
             if ($symb) {
                 if ($anchor ne '') {
@@ -3545,6 +3556,8 @@
             }
             if ($forceedit) {
                 $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1';
+            } elsif ($usehttp) {
+                $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1';
             }
             if ($forcereg) {
                 $cfile .= (($cfile=~/\?/)?'&':'?').'register=1';
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.466 loncom/interface/lonmenu.pm:1.467
--- loncom/interface/lonmenu.pm:1.466	Sat Jan 28 03:48:44 2017
+++ loncom/interface/lonmenu.pm	Sat Feb 18 23:39:16 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.466 2017/01/28 03:48:44 raeburn Exp $
+# $Id: lonmenu.pm,v 1.467 2017/02/18 23:39:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -503,6 +503,10 @@
                 } else {
                     $$menuitem[0] =~ s{\?register=1}{};
                 }
+                if (($ENV{'SERVER_PORT'} == 443) &&
+                    ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                    $$menuitem[0] .= ($$menuitem[0]=~/\?/) ? '&' : '?' . 'usehttp=1';
+                }
             }
             $menu .= &prep_menuitem(\@$menuitem);
         }
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.526 loncom/interface/lonnavmaps.pm:1.527
--- loncom/interface/lonnavmaps.pm:1.526	Sat Nov 26 01:47:04 2016
+++ loncom/interface/lonnavmaps.pm	Sat Feb 18 23:39:16 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.526 2016/11/26 01:47:04 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.527 2017/02/18 23:39:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1684,6 +1684,18 @@
 	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'}) {
@@ -1817,8 +1829,15 @@
 		$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;
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.141 loncom/interface/lonsyllabus.pm:1.142
--- loncom/interface/lonsyllabus.pm:1.141	Sat Feb 18 19:05:51 2017
+++ loncom/interface/lonsyllabus.pm	Sat Feb 18 23:39:16 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.141 2017/02/18 19:05:51 raeburn Exp $
+# $Id: lonsyllabus.pm,v 1.142 2017/02/18 23:39:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -309,6 +309,9 @@
             my $protocol = $Apache::lonnet::protocol{$homeserver};
             $protocol = 'http' if ($protocol ne 'https');
             my $link = $protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri;
+            if (($protocol eq 'https') && ($external =~ m{^http://})) {
+                $link .= '?usehttp=1';
+            }
             $r->print('<div class="LC_left_float">'
                      .'<span class="LC_help_open_topic LC_info">'
                      .'<span class="LC_info">'
@@ -627,11 +630,16 @@
 
 var regexp = $urlregexp;
 
-function extUrlPreview(caller) {
+function extUrlPreview(caller,protocol) {
     if (document.getElementById(caller)) {
         var url = document.getElementById(caller).value;
         if (regexp.test(url)) {
-            openMyModal(url,500,400,'yes');
+            var http_regex = /^http\:\/\//gi;
+            if ((protocol == 'https') && (http_regex.test(url))) {
+                window.open(url,"syllabuspreview","height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");
+            } else {
+                openMyModal(url,500,400,'yes');
+            }
         } else {
             alert("$invurl");
         }
@@ -819,6 +827,7 @@
         $checked{'templatebox'} = $check;
         $display{'templatebox'} = 'block';
     }
+    my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
 
     my $output = 
         '<form name="syllabus" method="post" enctype="multipart/form-data" action="">'."\n".
@@ -831,7 +840,7 @@
     $output .= '</fieldset></div>'."\n".
                '<div id="url" class="LC_left_float" style="display: '.$display{'url'}.'">'."\n".
                '<fieldset><legend>'.$lt{'chourl'}.'</legend><span class="LC_nobreak">'."\n".
-               '<a href="javascript:extUrlPreview('."'syllabusurl'".');">'.$lt{'pr'}.'</a></span> '."\n".
+               '<a href="javascript:extUrlPreview('."'syllabusurl','$protocol'".');">'.$lt{'pr'}.'</a></span> '."\n".
                '<input type="text" id="syllabusurl" name="externalsyllabus" value="'.$external.'" size="55" />'."\n".
                ' <input type="submit" name="storeurl" value="'.$lt{'save'}.'" />'."\n".
                '</fieldset></div>'."\n".
@@ -1132,6 +1141,10 @@
             (ref($courseenv) eq 'HASH')) {
         return ($earlyout,$uploaded,$external,$minimal,$output);
     }
+    my ($was_ext,$is_ext,$putres);
+    if ($external) {
+        $was_ext = $external;
+    }
     if (($env{'form.deleteuploaded_file'}) || ($env{'form.deleteuploaded_minimal'})) {
         my %storehash;
         if (($env{'form.choice'} eq 'file') && 
@@ -1144,7 +1157,7 @@
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
             $storehash{'uploadedsyllabus'} = '';
             $storehash{'externalsyllabus'} = '';
-            my $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
+            $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
             undef($uploaded);
             undef($external);
         } elsif (($env{'form.choice'} eq 'minimal') &&
@@ -1164,7 +1177,7 @@
             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.minimalsyllabus');
             $storehash{'externalsyllabus'} = '';
             $storehash{'minimalsyllabus'} = '';
-            my $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
+            $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
             undef($external);
             undef($minimal);
         }
@@ -1254,7 +1267,7 @@
         $syllabus->{'uploaded.domain'}=$env{'user.domain'};
         $syllabus->{'uploaded.name'}=$env{'user.name'};
         $syllabus->{'uploaded.lastmodified'} = $now;
-        my $putres = &Apache::lonnet::put('syllabus',$syllabus,$cdom,$cnum);
+        $putres = &Apache::lonnet::put('syllabus',$syllabus,$cdom,$cnum);
         if ($putres eq 'ok') {
             ($uploaded,$minimal,$external) = 
                 &update_syllabus_env($cdom,$cnum,$courseenv,$env{'form.choice'},$uploaded,
@@ -1279,7 +1292,7 @@
             } else {
                 $external=$env{'form.externalsyllabus'};
                 $external =~ s/(`)//g;
-                my $putres =
+                $putres =
                     &Apache::lonnet::put('environment',{externalsyllabus=>$external},
                                          $cdom,$cnum);
                 if ($putres eq 'ok') {
@@ -1296,6 +1309,7 @@
                               '</div>';
                 }
             }
+            $is_ext = $external;
         } else {
             $output = '<div class="LC_error">'.
                       &mt('External URL not saved -- invalid URL.').
@@ -1341,7 +1355,7 @@
             } else {
                 $storehash{'externalsyllabus'} = '',
             }
-            my $putres =
+            $putres =
                 &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
             if ($putres eq 'ok') {
                 &Apache::lonnet::make_public_indefinitely($url);
@@ -1406,6 +1420,22 @@
         $output = $result.&return_to_editor($cdom,$cnum);
         $earlyout = 1;
     }
+    if ($putres eq 'ok') {
+        if ((($is_ext) && ($is_ext ne $was_ext)) || ($was_ext)) {
+            my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
+            unless ($chome eq 'no_host') {
+                my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
+                if (ref($crsinfo{$cdom.'_'.$cnum}) eq 'HASH') {
+                    if ($external =~ m{^http://}) {
+                        $crsinfo{$cdom.'_'.$cnum}{'extsyllplain'} = 1;
+                    } elsif ($crsinfo{$cdom.'_'.$cnum}{'extsyllplain'}) {
+                        delete($crsinfo{$cdom.'_'.$cnum}{'extsyllplain'});
+                    }
+                    &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
+                }
+            }
+        }
+    }
     return ($earlyout,$uploaded,$external,$minimal,$output);
 }
 
Index: loncom/rewrites/loncapa_rewrite_on.conf
diff -u loncom/rewrites/loncapa_rewrite_on.conf:1.5 loncom/rewrites/loncapa_rewrite_on.conf:1.6
--- loncom/rewrites/loncapa_rewrite_on.conf:1.5	Tue Jan 26 14:30:30 2016
+++ loncom/rewrites/loncapa_rewrite_on.conf	Sat Feb 18 23:39:19 2017
@@ -8,6 +8,7 @@
     RewriteCond %{REQUEST_URI} ^/adm/annotations$
     RewriteRule (.*) - [L]
     RewriteCond %{REQUEST_URI} ^/public/.*/syllabus$
+    RewriteCond %{QUERY_STRING} (^|&)usehttp=1($|&)
     RewriteRule (.*) - [L]
     RewriteCond %{REQUEST_URI} ^/adm/jsMath/
     RewriteRule (.*) - [L]
Index: loncom/rewrites/loncapa_rewrite_off.conf
diff -u loncom/rewrites/loncapa_rewrite_off.conf:1.5 loncom/rewrites/loncapa_rewrite_off.conf:1.6
--- loncom/rewrites/loncapa_rewrite_off.conf:1.5	Tue Jan 26 14:30:30 2016
+++ loncom/rewrites/loncapa_rewrite_off.conf	Sat Feb 18 23:39:19 2017
@@ -8,6 +8,7 @@
     RewriteCond %{REQUEST_URI} ^/adm/annotations$
     RewriteRule (.*) - [L]
     RewriteCond %{REQUEST_URI} ^/public/.*/syllabus$
+    RewriteCond %{QUERY_STRING} (^|&)usehttp=1($|&)
     RewriteRule (.*) - [L]
     RewriteCond %{REQUEST_URI} ^/adm/jsMath/
     RewriteRule (.*) - [L]
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.91 rat/lonpageflip.pm:1.92
--- rat/lonpageflip.pm:1.91	Mon May 30 02:52:42 2016
+++ rat/lonpageflip.pm	Sat Feb 18 23:39:24 2017
@@ -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 @@
 	    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 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 @@
 	    $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 @@
 # ------------------------------------- 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 @@
 <tr><th>$lt{'titleheader'}</th><th>$lt{'type'}</th></tr>
 ENDSTART
                      foreach my $id (@possibilities) {
+                        my $src = $multichoicehash{'src_'.$id};
+                        &check_for_syllabus(\$src);
                         $r->print(
                               '<tr><td><a href="'.
-				  &add_get_param($multichoicehash{'src_'.$id},
+				  &add_get_param($src,
 						 {'symb' =>
 						      $multichoicehash{'symb_'.$id},
 						  }).'">'.


More information about the LON-CAPA-cvs mailing list