[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm

raeburn raeburn@source.lon-capa.org
Fri, 20 Aug 2010 17:53:40 -0000


raeburn		Fri Aug 20 17:53:40 2010 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
  Log:
  - Bug 6067, 6310.
    - Javascript confirm pop-up to warn of server switch.
    - orgurl not needed in switchserver query string if symb is provided. 
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.335 loncom/interface/lonmenu.pm:1.336
--- loncom/interface/lonmenu.pm:1.335	Fri Aug 20 08:13:41 2010
+++ loncom/interface/lonmenu.pm	Fri Aug 20 17:53:40 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.335 2010/08/20 08:13:41 wenzelju Exp $
+# $Id: lonmenu.pm,v 1.336 2010/08/20 17:53:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -525,15 +525,18 @@
                 if ($nocrsedit) {
                     $editbutton=&clear(6,1);
                 } else {
+                    my $bot = "go('$cfile')";
                     if ($switchserver) {
                         if ( $env{'request.symb'} && $env{'request.course.id'} ) {
-                            my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
-                            $cfile = '/adm/switchserver?otherserver='.$home.'&role='.$env{'request.role'}.'&symb='.$env{'request.symb'}.'&origurl='.$resurl;
+                            $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
+                                     &HTML::Entities::encode($env{'request.role'},'"<>&').'&amp;symb='.
+                                     &HTML::Entities::encode($env{'request.symb'},'"<>&');
+                            $bot = "need_switchserver('$cfile');";
                         }
                     }
                     $editbutton=&switch
                        ('','',6,1,'pcstr.png','edit[_1]','resource[_2]',
-                     "go('".$cfile."');","Edit this resource");
+                        $bot,"Edit this resource");
                     $noeditbutton = 0;
                 }
             } elsif ($editbutton eq '') {
@@ -1113,6 +1116,9 @@
     my $end_page_bookmark = 
         &Apache::loncommon::end_page({'js_ready' => 1});
 
+    my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
+                         &mt('Switch server?');
+
     my $start_page_wishlistlink = 
         &Apache::loncommon::start_page('Set link to wishlist',undef,
 				       {'only_body' => 1,
@@ -1172,6 +1178,15 @@
    }
 }
 
+function need_switchserver(url) {
+    if (url!='' && url!= null) {
+        if (confirm("$confirm_switch")) {
+            go(url); 
+        }
+    }
+    return;
+}
+
 function gopost(url,postdata) {
    if (url!='') {
       this.document.server.action=url;