[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/interface loncommon.pm lonmenu.pm loncom/rewrites loncapa_rewrite_off.conf loncapa_rewrite_on.conf

raeburn raeburn at source.lon-capa.org
Sat Sep 7 15:58:08 EDT 2013


raeburn		Sat Sep  7 19:58:08 2013 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmenu.pm 
    /loncom/rewrites	loncapa_rewrite_on.conf loncapa_rewrite_off.conf 
    /rat	lonwrapper.pm 
  Log:
  - Bug 6662
    - External Resource items in which the remote URL is http:// need to be
      served from port 80, if the LON-CAPA server hosting the session has
      Apache/SSL.
  
   -  In addition to committed changes in LON-CAPA modules, an appropriate
      RewriteRule is also needed for <VirtualHost _default_:443> (e.g., 
      in /etc/httpd/conf.d/ssl.conf on the LON-CAPA server. (see:
      http://bugs.loncapa.org/show_bug.cgi?id=6662).
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1153 loncom/interface/loncommon.pm:1.1154
--- loncom/interface/loncommon.pm:1.1153	Fri Sep  6 00:34:57 2013
+++ loncom/interface/loncommon.pm	Sat Sep  7 19:58:01 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1153 2013/09/06 00:34:57 raeburn Exp $
+# $Id: loncommon.pm,v 1.1154 2013/09/07 19:58:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1393,17 +1393,18 @@
 }
 
 sub help_menu_js {
-    my ($text) = @_;
+    my ($httphost) = @_;
     my $stayOnPage = 1;
     my $width = 620;
     my $height = 600;
     my $helptopic=&general_help();
-    my $details_link = '/adm/help/'.$helptopic.'.hlp';
+    my $details_link = $httphost.'/adm/help/'.$helptopic.'.hlp';
     my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
     my $start_page =
         &Apache::loncommon::start_page('Help Menu', undef,
 				       {'frameset'    => 1,
 					'js_ready'    => 1,
+                                        'use_absolute' => $httphost,
 					'add_entries' => {
 					    'border' => '0',
 					    'rows'   => "110,*",},});
@@ -5124,6 +5125,7 @@
         $public = 1;
     }
     if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
+    my $httphost = $args->{'use_absolute'};
 
     $function = &get_users_function() if (!$function);
     my $img =    &designparm($function.'.img',$domain);
@@ -5196,7 +5198,7 @@
         #    }
 
         $bodytag .= Apache::lonhtmlcommon::scripttag(
-            Apache::lonmenu::utilityfunctions(), 'start');
+            Apache::lonmenu::utilityfunctions($httphost), 'start');
 
         my ($left,$right) = Apache::lonmenu::primary_menu();
 
@@ -5222,7 +5224,7 @@
 
         #don't show menus for public users
         if (!$public){
-            $bodytag .= Apache::lonmenu::secondary_menu();
+            $bodytag .= Apache::lonmenu::secondary_menu($httphost);
             $bodytag .= Apache::lonmenu::serverform();
             $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
             if ($env{'request.state'} eq 'construct') {
@@ -7269,6 +7271,7 @@
     my $function = $args->{'function'} || &get_users_function();
     my $domain   = $args->{'domain'}   || &determinedomain();
     my $bgcolor  = $args->{'bgcolor'}  || &designparm($function.'.pgbg',$domain);
+    my $httphost = $args->{'use_absolute'};
     my $url = join(':',$env{'user.name'},$env{'user.domain'},
 		   $Apache::lonnet::perlvar{'lonVersion'},
 		   #time(),
@@ -7292,7 +7295,7 @@
     if (!$args->{'no_nav_bar'} 
 	&& !$args->{'only_body'}
 	&& !$args->{'frameset'}) {
-	$result .= &help_menu_js();
+	$result .= &help_menu_js($httphost);
         $result.=&modal_window();
         $result.=&togglebox_script();
         $result.=&wishlist_window();
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.420 loncom/interface/lonmenu.pm:1.421
--- loncom/interface/lonmenu.pm:1.420	Tue Aug 13 14:17:00 2013
+++ loncom/interface/lonmenu.pm	Sat Sep  7 19:58:01 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.420 2013/08/13 14:17:00 raeburn Exp $
+# $Id: lonmenu.pm,v 1.421 2013/09/07 19:58:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -313,6 +313,7 @@
 }
 
 sub secondary_menu {
+    my ($httphost) = @_;
     my $menu;
 
     my $crstype = &Apache::loncommon::course_type();
@@ -417,7 +418,8 @@
             ($roleswitcher_js,$roleswitcher_form,my $switcher) =
                 &roles_selector(
                         $env{'course.' . $env{'request.course.id'} . '.domain'},
-                        $env{'course.' . $env{'request.course.id'} . '.num'}
+                        $env{'course.' . $env{'request.course.id'} . '.num'},
+                        $httphost
                 );
             $menu .= $switcher;
         } else {
@@ -1443,6 +1445,7 @@
 }
 
 sub utilityfunctions {
+    my ($httphost) = @_;
     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
     if ($currenturl =~ m{^/adm/wrapper/ext/}
         && $env{'request.external.querystring'} ) {
@@ -1478,7 +1481,7 @@
     my $countdown = &countdown_toggle_js();
 
 return (<<ENDUTILITY)
-
+    var host="$httphost";
     var currentURL=unescape("$esc_url");
     var reloadURL=unescape("$esc_url");
     var currentSymb=unescape("$esc_symb");
@@ -1489,7 +1492,7 @@
 
 function gopost(url,postdata) {
    if (url!='') {
-      this.document.server.action=url;
+      this.document.server.action=host+url;
       this.document.server.postdata.value=postdata;
       this.document.server.command.value='';
       this.document.server.url.value='';
@@ -1500,7 +1503,7 @@
 
 function gocmd(url,cmd) {
    if (url!='') {
-      this.document.server.action=url;
+      this.document.server.action=host+url;
       this.document.server.postdata.value='';
       this.document.server.command.value=cmd;
       this.document.server.url.value=currentURL;
@@ -1552,7 +1555,7 @@
    if (url!='' && url!= null) {
        currentURL = null;
        currentSymb= null;
-       top.location.href=url;
+       top.location.href=host+url;
    }
 }
 
@@ -1563,11 +1566,11 @@
 }
 
 function chat_win() {
-   lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
+   lonchat=window.open(host+'/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
 }
 
 function group_chat(group) {
-   var url = '/adm/groupchat?group='+group;
+   var url = host+'/adm/groupchat?group='+group;
    var winName = 'LONchat_'+group;
    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 }
@@ -1588,11 +1591,11 @@
 function open_StoredLinks_Import(rat) {
    var newWin;
    if (rat) {
-       newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
+       newWin = window.open(host+'/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
    }
    else {
-       newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
+       newWin = window.open(host+'/adm/wishlist?inhibitmenu=yes&mode=import',
                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
    }
    newWin.focus();
@@ -1657,7 +1660,7 @@
 }
 
 sub roles_selector {
-    my ($cdom,$cnum) = @_;
+    my ($cdom,$cnum,$httphost) = @_;
     my $crstype = &Apache::loncommon::course_type();
     my $now = time;
     my (%courseroles,%seccount,%courseprivs);
@@ -1762,7 +1765,7 @@
         my @submenu;
         $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
         $form = 
-            '<form name="rolechooser" method="post" action="/adm/roles">'."\n".
+            '<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n".
             '  <input type="hidden" name="destinationurl" value="'.
             &HTML::Entities::encode($destinationurl).'" />'."\n".
             '  <input type="hidden" name="gotorole" value="1" />'."\n".
Index: loncom/rewrites/loncapa_rewrite_on.conf
diff -u loncom/rewrites/loncapa_rewrite_on.conf:1.1 loncom/rewrites/loncapa_rewrite_on.conf:1.2
--- loncom/rewrites/loncapa_rewrite_on.conf:1.1	Thu May 26 01:05:44 2011
+++ loncom/rewrites/loncapa_rewrite_on.conf	Sat Sep  7 19:58:04 2013
@@ -3,6 +3,10 @@
     RewriteEngine on
     RewriteCond %{REMOTE_HOST} 127.0.0.1
     RewriteRule (.*) - [L]
+    RewriteCond %{REQUEST_URI} ^/adm/wrapper/ext/(?!https:)
+    RewriteRule (.*) - [L]
+    RewriteCond %{REQUEST_URI} ^/adm/annotations$
+    RewriteRule (.*) - [L]
     RewriteCond %{HTTPS} !=on
     RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [R,L]
   </IfModule>
Index: loncom/rewrites/loncapa_rewrite_off.conf
diff -u loncom/rewrites/loncapa_rewrite_off.conf:1.1 loncom/rewrites/loncapa_rewrite_off.conf:1.2
--- loncom/rewrites/loncapa_rewrite_off.conf:1.1	Thu May 26 01:05:44 2011
+++ loncom/rewrites/loncapa_rewrite_off.conf	Sat Sep  7 19:58:04 2013
@@ -3,6 +3,10 @@
     RewriteEngine off
     RewriteCond %{REMOTE_HOST} 127.0.0.1
     RewriteRule (.*) - [L]
+    RewriteCond %{REQUEST_URI} ^/adm/wrapper/ext/(?!https:)
+    RewriteRule (.*) - [L]
+    RewriteCond %{REQUEST_URI} ^/adm/annotations$
+    RewriteRule (.*) - [L]
     RewriteCond %{HTTPS} !=on
     RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [R,L]
   </IfModule>
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.43 rat/lonwrapper.pm:1.44
--- rat/lonwrapper.pm:1.43	Thu Nov 29 20:13:49 2012
+++ rat/lonwrapper.pm	Sat Sep  7 19:58:08 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.43 2012/11/29 20:13:49 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.44 2013/09/07 19:58:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,7 +40,7 @@
 
 # ================================================================ Main Handler
 sub wrapper {
-    my ($url,$brcrum) = @_;
+    my ($url,$brcrum,$absolute) = @_;
 
     my $forcereg;
     unless ($env{'form.folderpath'}) {
@@ -54,6 +54,9 @@
     if (ref($brcrum) eq 'ARRAY') {
          $args->{'bread_crumbs'} = $brcrum;
     }
+    if ($absolute) {
+        $args->{'use_absolute'} = $absolute; 
+    }
 
     my $startpage =  Apache::loncommon::start_page('Menu',undef,$args);
     my $endpage =  Apache::loncommon::end_page();
@@ -103,7 +106,7 @@
     return OK if $r->header_only;
 
     my $url = $r->uri;
-    my ($is_ext,$brcrum);
+    my ($is_ext,$brcrum,$absolute);
 
     for ($url){
         s|^/adm/wrapper||;
@@ -113,6 +116,15 @@
     }
 
     if ($is_ext) {
+        my $hostname = $r->hostname();
+        my $lonhost = &Apache::lonnet::host_from_dns($hostname);
+        if ($lonhost) {
+            my $actual = &Apache::lonnet::absolute_url($hostname);
+            my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname; 
+            unless ($actual eq $expected) {
+                $absolute = $expected;
+            }
+        }
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
             ['forceedit','register','folderpath','symb','idx','title']);
         if (($env{'form.forceedit'}) &&
@@ -160,7 +172,7 @@
         # encrypt url if not external
         &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
 
-        $r->print( wrapper($url,$brcrum) );
+        $r->print( wrapper($url,$brcrum,$absolute) );
 
     } # not just the menu
     


More information about the LON-CAPA-cvs mailing list