[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface londocs.pm

raeburn raeburn at source.lon-capa.org
Fri Jul 26 19:33:35 EDT 2019


raeburn		Fri Jul 26 23:33:35 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	londocs.pm 
  Log:
  - For 2.11
    Backport 1.621 (part), 1.622, 1.623 (part), 1.657, 1.658, 1.659
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.79 loncom/interface/londocs.pm:1.484.2.80
--- loncom/interface/londocs.pm:1.484.2.79	Thu Apr 11 16:32:33 2019
+++ loncom/interface/londocs.pm	Fri Jul 26 23:33:34 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.484.2.79 2019/04/11 16:32:33 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.80 2019/07/26 23:33:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -834,7 +834,7 @@
              '// <![CDATA['."\n".
              &Apache::loncommon::display_filter_js('docslog')."\n".
              &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
-                         $coursedom,$coursenum,$canedit,\$navmap)."\n".
+                         $coursedom,$coursenum,$canedit,'',\$navmap)."\n".
              &history_tab_js()."\n".
              &Apache::lonratedt::editscript('simple')."\n".
              '// ]]>'."\n".
@@ -2775,8 +2775,8 @@
 
 sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
-        $supplementalflag,$orderhash,$iconpath,$pathitem,$canedit,$navmapref,
-        $hiddentop)=@_;
+        $supplementalflag,$orderhash,$iconpath,$pathitem,$canedit,
+        $hostname,$navmapref,$hiddentop)=@_;
     my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
     if ($allowed) {
         (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
@@ -3096,7 +3096,7 @@
                               $coursenum,$coursedom,$crstype,
                               $pathitem,$supplementalflag,$container,
                               \%filters,\%curr_groups,$canedit,
-                              $isencrypted,$navmapref);
+                              $isencrypted,$navmapref,$hostname);
         $idx++;
         $shown++;
     }
@@ -3475,7 +3475,7 @@
 sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
         $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
-        $canedit,$isencrypted,$navmapref)=@_;
+        $canedit,$isencrypted,$navmapref,$hostname)=@_;
     my ($foldertitle,$renametitle,$oldtitle);
     if (&is_supplemental_title($title)) {
 	($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
@@ -3752,6 +3752,9 @@
             } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
                 if (($ENV{'SERVER_PORT'} == 443) &&
                     ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                    unless (&Apache::lonnet::uses_sts()) {
+                        $url .= '?usehttp=1';
+                    }
                     $nomodal = 1;
                 }
 	    }
@@ -3761,9 +3764,8 @@
                     if ($url =~ /^([^#]+)#([^#]+)$/) {
                         $url = $1;
                         $anchor = $2;
-                        if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
-                            $shownsymb = $1.&escape('#').$anchor;
-                        }
+                        my $escan = &escape('#');
+                        $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;
                     }
                 }
                 unless ($env{'request.role.adv'}) {
@@ -3797,7 +3799,7 @@
                     my $shownsymb = &Apache::lonenc::encrypted($symb);
                     my $shownurl = &Apache::lonenc::encrypted($url);
                     if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
-                        $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+                        $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                         if ($env{'request.enc'} ne '') {
                             delete($env{'request.enc'});
                         }
@@ -3817,12 +3819,24 @@
                 $url = $1;
                 $anchor = $2;
                 if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
+                    unless (&Apache::lonnet::uses_sts()) {
+                        if ($hostname ne '') {
+                            $url = 'http://'.$hostname.$url;
+                        }
+                        $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
+                    }
                     $nomodal = 1;
                 }
             }
         } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
             if (($ENV{'SERVER_PORT'} == 443) &&
                 ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                unless (&Apache::lonnet::uses_sts()) {
+                    if ($hostname ne '') {
+                        $url = 'http://'.$hostname.$url;
+                    }
+                    $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
+                }
                 $nomodal = 1;
             }
         }
@@ -3947,7 +3961,8 @@
                                                             $forceedit,
                                                             undef,$symb,
                                                             &escape($env{'form.folderpath'}),
-                                                            $renametitle,'','',1,$suppanchor);
+                                                            $renametitle,$hostname,
+                                                            '','',1,$suppanchor);
                 if ($jscall) {
                     $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
                                 $jscall.'" >'.&mt('Edit').'</a> '."\n";
@@ -3975,8 +3990,13 @@
                $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
            }
        }
-       $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
-                                               (($anchor ne '')?$anchor:''));
+
+       if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
+           $link = 'http://'.$hostname.$url;
+       } else {
+           $link = $url;
+       }
+       $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$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>';
@@ -5162,8 +5182,9 @@
                 }
             }
             my $tabidstr = join("','", at tabids);
+            my $hostname = $r->hostname();
 	    $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,
-                                   $canedit,\$navmap).
+                                   $canedit,$hostname,\$navmap).
                        &history_tab_js().
                        &inject_data_js().
                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
@@ -6299,7 +6320,8 @@
 }
 
 sub editing_js {
-    my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$canedit,$navmapref) = @_;
+    my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,
+        $canedit,$hostname,$navmapref) = @_;
     my %js_lt = &Apache::lonlocal::texthash(
                                           p_mnf => 'Name of New Folder',
                                           t_mnf => 'New Folder',
@@ -6373,6 +6395,26 @@
                 }
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
                              &HTML::Entities::encode($caller,'<>&"');
+                if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
+                    if (($ENV{'SERVER_PORT'} == 443) &&
+                        ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
+                        unless (&Apache::lonnet::uses_sts()) {
+                            if ($hostname ne '') {
+                                $backtourl = 'http://'.$hostname.$backtourl;
+                            }
+                            $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
+                        }
+                    }
+                } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
+                    if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
+                        unless (&Apache::lonnet::uses_sts()) {
+                            if ($hostname ne '') {
+                                $backtourl = 'http://'.$hostname.$backtourl;
+                            }
+                            $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
+                        }
+                    }
+                }
                 if ($anchor ne '') {
                     $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
                 }


More information about the LON-CAPA-cvs mailing list