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

raeburn raeburn at source.lon-capa.org
Tue Jul 2 18:03:11 EDT 2024


raeburn		Tue Jul  2 22:03:11 2024 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonhtmlcommon.pm 
  Log:
  - For 2.11
    Backport 1.406 (part) 
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.358.2.21 loncom/interface/lonhtmlcommon.pm:1.358.2.22
--- loncom/interface/lonhtmlcommon.pm:1.358.2.21	Tue Jul  2 02:29:13 2024
+++ loncom/interface/lonhtmlcommon.pm	Tue Jul  2 22:03:11 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.358.2.21 2024/07/02 02:29:13 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.358.2.22 2024/07/02 22:03:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3433,7 +3433,10 @@
 sub javascript_jumpto_resource {
     my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n".
                          &mt('Switch server?');
+    my $confirm_new_tab = &mt("Editing requires using the resource's home server.")."\n".
+                          &mt('Open a new browser tab?');
     &js_escape(\$confirm_switch);
+    &js_escape(\$confirm_new_tab);
     return (<<ENDUTILITY)
 
 function go(url) {
@@ -3454,9 +3457,13 @@
    }
 }
 
-function need_switchserver(url) {
+function need_switchserver(url,target) {
     if (url!='' && url!= null) {
-        if (confirm("$confirm_switch")) {
+        if (target == '_blank') {
+            if (confirm("$confirm_new_tab")) {
+                window.open(url,target);
+            }
+        } else if (confirm("$confirm_switch")) {
             go(url);
         }
     }
@@ -3468,15 +3475,31 @@
 }
 
 sub jump_to_editres {
-    my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
-        $title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_;
-    my ($jscall,$anchor,$usehttp,$usehttps,$is_ext);
+    my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$shownsymb,
+        $folderpath,$title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_;
+    my ($jscall,$anchor,$usehttp,$usehttps,$is_ext,$target);
     if ($switchserver) {
         if ($home) {
+            my $resedit;
+            if ($cfile =~ m{^/priv/($match_domain)/($match_username)/}) {
+                my ($audom,$auname) = ($1,$2);
+                unless (&Apache::lonnet::is_course($audom,$auname)) {
+                    if (($symb ne '') && ($env{'request.course.id'}) &&
+                        (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+                        unless (&Apache::lonnet::can_switchserver($env{'user.domain'},$home)) {
+                            $target = '_blank';
+                            $resedit = 1;
+                        }
+                    }
+                }
+            }
             $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
                      &HTML::Entities::encode($env{'request.role'},'"<>&');
-            if ($symb) {
-                $cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&');
+            if ($shownsymb) {
+                $cfile .= '&symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+                if ($resedit) {
+                    $cfile .= '&edit=1';
+                }
             } elsif ($folderpath) {
                 $cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&');
             }
@@ -3486,7 +3509,7 @@
             if ($forcereg) {
                 $cfile .= '&register=1';
             }
-            $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."');";
+            $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."','$target');";
         }
     } else {
         unless ($cfile =~ m{^/priv/}) {




More information about the LON-CAPA-cvs mailing list