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

raeburn raeburn@source.lon-capa.org
Mon, 14 Jun 2010 00:35:43 -0000


raeburn		Mon Jun 14 00:35:43 2010 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
  Log:
  - Bug 6310.
    - "Edit this resource" link shown on servers besides home server of reso
  urce, if user has (co-)author privs for resource.
    - work in progress: javascript confirm still needed about impending
      server switch.
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.329 loncom/interface/lonmenu.pm:1.330
--- loncom/interface/lonmenu.pm:1.329	Sun Jun  6 11:56:12 2010
+++ loncom/interface/lonmenu.pm	Mon Jun 14 00:35:43 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.329 2010/06/06 11:56:12 droeschl Exp $
+# $Id: lonmenu.pm,v 1.330 2010/06/14 00:35:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -488,6 +488,8 @@
             my $cfuname='';
             my $cfudom='';
             my $uploaded;
+            my $switchserver='';
+            my $home;
             if ($env{'request.filename'}) {
                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
                 if (defined($cnum) && defined($cdom)) {
@@ -498,18 +500,20 @@
                     # Check that the user has permission to edit this resource
                     ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
                     if (defined($cfudom)) {
-		        my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
+		        $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
 		        my $allowed=0;
 		        my @ids=&Apache::lonnet::current_machine_ids();
 		        foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
 		        if ($allowed) {
                             $cfile=$file;
+                        } else {
+                            $switchserver=$file;
                         }
                     }
                 }
             }
             # Finally, turn the button on or off
-            if ($cfile && !$const_space) {
+            if (($cfile || $switchserver) && !$const_space) {
                 my $nocrsedit;
                 # Suppress display where CC has switched to student role.
                 if ($env{'request.course.id'}) {
@@ -521,6 +525,12 @@
                 if ($nocrsedit) {
                     $editbutton=&clear(6,1);
                 } else {
+                    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;
+                        }
+                    }
                     $editbutton=&switch
                        ('','',6,1,'pcstr.png','edit[_1]','resource[_2]',
                      "go('".$cfile."');","Edit this resource");