Diff for /loncom/interface/lonmenu.pm between versions 1.244.2.17 and 1.244.2.18

version 1.244.2.17, 2010/05/24 12:20:16 version 1.244.2.18, 2010/08/20 17:59:04
Line 557  sub innerregister { Line 557  sub innerregister {
             my $cfuname='';              my $cfuname='';
             my $cfudom='';              my $cfudom='';
             my $uploaded;              my $uploaded;
               my $switchserver='';
               my $home;
             if ($env{'request.filename'}) {              if ($env{'request.filename'}) {
                 my $file=&Apache::lonnet::declutter($env{'request.filename'});                  my $file=&Apache::lonnet::declutter($env{'request.filename'});
                 $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;                  $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
                 # Check that the user has permission to edit this resource                  # Check that the user has permission to edit this resource
                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);                  ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
                 if (defined($cfudom)) {                  if (defined($cfudom)) {
     my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);      $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
     my $allowed=0;      my $allowed=0;
     my @ids=&Apache::lonnet::current_machine_ids();      my @ids=&Apache::lonnet::current_machine_ids();
     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }      foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
     if ($allowed) {      if ($allowed) {
                         $cfile=$file;                          $cfile=$file;
                       }  else {
                           $switchserver=$file;
                     }                      }
                 }                  }
             }                      }        
             # Finally, turn the button on or off              # Finally, turn the button on or off
             if ($cfile && !$const_space) {              if (($cfile || $switchserver) && !$const_space) {
                 my $nocrsedit;                  my $nocrsedit;
                 # Suppress display where CC has switched to student role.                  # Suppress display where CC has switched to student role.
                 if ($env{'request.course.id'}) {                  if ($env{'request.course.id'}) {
Line 585  sub innerregister { Line 589  sub innerregister {
                 if ($nocrsedit) {                  if ($nocrsedit) {
                     $editbutton=&clear(6,1);                      $editbutton=&clear(6,1);
                 } else {                  } 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'},'"<>&').'&amp;symb='.
                                        &HTML::Entities::encode($env{'request.symb'},'"<>&');
                           }
                           $bot = "need_switchserver('$cfile');";
                       }
                     $editbutton=&switch                      $editbutton=&switch
                        ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',                         ('','',6,1,'pcstr.png','edit[_1]','resource[_2]',
                      "go('".$cfile."');","Edit this resource");                         $bot,"Edit this resource");
                     $noeditbutton = 0;                      $noeditbutton = 0;
                 }                  }
             } elsif ($editbutton eq '') {              } elsif ($editbutton eq '') {
Line 1513  sub utilityfunctions { Line 1526  sub utilityfunctions {
     my $end_page_bookmark =       my $end_page_bookmark = 
         &Apache::loncommon::end_page({'js_ready' => 1});          &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 (<<ENDUTILITY)  return (<<ENDUTILITY)
   
     var currentURL="$currenturl";      var currentURL="$currenturl";
Line 1529  function go(url) { Line 1545  function go(url) {
    }     }
 }  }
   
   function need_switchserver(url) {
       if (url!='' && url!= null) {
           if (confirm("$confirm_switch")) {
               go(url);
           }
       }
       return;
   }
   
 function gopost(url,postdata) {  function gopost(url,postdata) {
    if (url!='') {     if (url!='') {
       this.document.server.action=url;        this.document.server.action=url;

Removed from v.1.244.2.17  
changed lines
  Added in v.1.244.2.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>