--- loncom/interface/lonmenu.pm 2010/05/24 12:20:16 1.244.2.17 +++ loncom/interface/lonmenu.pm 2010/08/20 17:59:04 1.244.2.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.17 2010/05/24 12:20:16 raeburn Exp $ +# $Id: lonmenu.pm,v 1.244.2.18 2010/08/20 17:59:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -557,23 +557,27 @@ sub innerregister { my $cfuname=''; my $cfudom=''; my $uploaded; + my $switchserver=''; + my $home; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; # 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'}) { @@ -585,9 +589,18 @@ sub innerregister { if ($nocrsedit) { $editbutton=&clear(6,1); } else { + my $bot = "go('$cfile')"; + if ($switchserver) { + if ( $env{'request.symb'} && $env{'request.course.id'} ) { + $cfile = '/adm/switchserver?otherserver='.$home.'&role='. + &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='. + &HTML::Entities::encode($env{'request.symb'},'"<>&'); + } + $bot = "need_switchserver('$cfile');"; + } $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', - "go('".$cfile."');","Edit this resource"); + ('','',6,1,'pcstr.png','edit[_1]','resource[_2]', + $bot,"Edit this resource"); $noeditbutton = 0; } } elsif ($editbutton eq '') { @@ -1513,6 +1526,9 @@ sub utilityfunctions { my $end_page_bookmark = &Apache::loncommon::end_page({'js_ready' => 1}); + my $confirm_switch = &mt("Editing requires switching to the reource's home server.").'\n'. + &mt('Switch server?'); + return (<