Diff for /loncom/interface/lonmenu.pm between versions 1.222 and 1.234

version 1.222, 2007/07/17 18:31:37 version 1.234, 2008/02/03 05:07:58
Line 54  my @inlineremote; Line 54  my @inlineremote;
   
   
 # ================================================================ Little texts  # ================================================================ Little texts
   sub show_course {
       my $course = !$env{'user.adv'};
       if (!$env{'user.adv'}) {
    foreach my $env (keys(%env)) {
       next if ($env !~ m/^user\.priv\./);
       if ($env !~ m/^user\.priv\.(?:st|cm)/) {
    $course = 0;
    last;
       }
    }
       }
       return $course;
   }
   
 sub initlittle {  sub initlittle {
     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',      return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
        'nav' => 'Navigate Contents',         'nav' => 'Navigate Contents',
        'main' => 'Main Menu',         'main' => 'Main Menu',
                                        'roles' => ($env{'user.adv'}?                                         'roles' => (&show_course()?
                                                     'Roles':'Courses'),                                                      'Courses':'Roles'),
                                        'docs' => 'Edit Course',                                         'docs' => 'Edit Course',
                                        'exit' => 'Exit',                                         'exit' => 'Exit',
                                        'login' => 'Log In',                                         'login' => 'Log In',
Line 121  sub menubuttons { Line 134  sub menubuttons {
     $navmaps=(<<ENDNAV);      $navmaps=(<<ENDNAV);
 <a href="/adm/navmaps?postdata=$escurl&amp;postsymb=$escsymb" target="_top">$lt{'nav'}</a>  <a href="/adm/navmaps?postdata=$escurl&amp;postsymb=$escsymb" target="_top">$lt{'nav'}</a>
 ENDNAV  ENDNAV
             if (($env{'request.noversionuri'}=~/^\/adm\//) &&              if (&show_return_link()) {
          ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&  
          ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {  
                 my $escreload=&escape('return:');                  my $escreload=&escape('return:');
                 $reloadlink=(<<ENDRELOAD);                  $reloadlink=(<<ENDRELOAD);
 <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>  <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
Line 196  ENDINLINEMENU Line 207  ENDINLINEMENU
     $navmaps=(<<ENDNAV);      $navmaps=(<<ENDNAV);
 <td><a href="$link" target="_top">$lt{'nav'}</a></td>  <td><a href="$link" target="_top">$lt{'nav'}</a></td>
 ENDNAV  ENDNAV
 my $is_group = (&Apache::loncommon::course_type() eq 'Group');              my $is_group = (&Apache::loncommon::course_type() eq 'Group');
     if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {      if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                 my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};                  my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
  $docs=(<<ENDDOCS);   $docs=(<<ENDDOCS);
Line 208  ENDDOCS Line 219  ENDDOCS
 <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>  <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>
 ENDGROUPS  ENDGROUPS
             }              }
     if (      if (&show_return_link()) {
  ($env{'request.noversionuri'}=~m[^/(res|public)/] &&  
  $env{'request.symb'} eq '')  
  ||  
  (($env{'request.noversionuri'}=~/^\/adm\//) &&  
  ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&  
  ($env{'request.noversionuri'}!~  
         m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])  
   )  
  ) {  
                 my $escreload=&escape('return:');                  my $escreload=&escape('return:');
                 $reloadlink=(<<ENDRELOAD);                  $reloadlink=(<<ENDRELOAD);
 <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>  <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
Line 274  ENDINLINEMENU Line 276  ENDINLINEMENU
     }      }
 }  }
   
   sub show_return_link {
       return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
        $env{'request.symb'} eq '')
       ||
       ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
       ||
       (($env{'request.noversionuri'}=~/^\/adm\//) &&
        ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
        ($env{'request.noversionuri'}!~
         m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
        ));
   }
   
 # ====================================== This gets called in the header section  # ====================================== This gets called in the header section
   
 sub registerurl {  sub registerurl {
Line 334  sub innerregister { Line 349  sub innerregister {
  } else {   } else {
     $newmail= 'swmenu.setstatus("you have","messages");';      $newmail= 'swmenu.setstatus("you have","messages");';
  }   }
     } elsif (($textual)       } 
       if (($textual) 
      && ($env{'request.symb'})        && ($env{'request.symb'}) 
      && ($env{'request.course.id'})) {       && ($env{'request.course.id'})) {
  $newmail.= '<td class="LC_current_location">';   $newmail.= '<td class="LC_current_location">';
  my ($mapurl,$rid,$resurl)=   my ($mapurl,$rid,$resurl)=
     &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());      &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
         $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};          my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
           $newmail.=$coursetitle;
         my $maptitle=&Apache::lonnet::gettitle($mapurl);          my $maptitle=&Apache::lonnet::gettitle($mapurl);
  my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());   my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
         if ($maptitle && $maptitle ne 'default.sequence') {          if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
     $newmail.=', '.$maptitle;      $newmail.=', '.$maptitle;
         }          }
         if ($restitle) {          if ($restitle) {
Line 398  sub innerregister { Line 415  sub innerregister {
         ###          ###
         my $editbutton = '';          my $editbutton = '';
         if ($env{'user.author'}) {          if ($env{'user.author'}) {
             if ($env{'request.role'}=~/^(ca|au)/) {              if ($env{'request.role'}=~/^(aa|ca|au)/) {
                 # Set defaults for authors                  # Set defaults for authors
                 my ($top,$bottom) = ('con-','struct');                  my ($top,$bottom) = ('con-','struct');
                 my $action = "go('/priv/".$env{'user.name'}."');";                  my $action = "go('/priv/".$env{'user.name'}."');";
Line 411  sub innerregister { Line 428  sub innerregister {
                     ($top,$bottom) = ('co con-','struct');                      ($top,$bottom) = ('co con-','struct');
                     $action = "go('/priv/".$caname."');";                      $action = "go('/priv/".$caname."');";
                     $desc = "Enter construction space as co-author";                      $desc = "Enter construction space as co-author";
                   } elsif ($env{'request.role'} =~ /^aa/) {
                       ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
                       ($top,$bottom) = ('co con-','struct');
                       $action = "go('/priv/".$caname."');";
                       $desc = "Enter construction space as assistant co-author";
                 }                  }
                 # Check that we are on the correct machine                  # Check that we are on the correct machine
                 my $home = &Apache::lonnet::homeserver($caname,$cadom);                  my $home = &Apache::lonnet::homeserver($caname,$cadom);
Line 547  $inlineremote[91] $inlineremote[92] $inl Line 569  $inlineremote[91] $inlineremote[92] $inl
 ENDINLINEICONS  ENDINLINEICONS
                         }                          }
                     } else {                      } else {
  $inlinebuttons=(<<ENDFIRSTLINE);   if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
       $inlinebuttons=(<<ENDFIRSTLINE);
 <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>  <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>
 ENDFIRSTLINE  ENDFIRSTLINE
                         if (&hidden_button_check() ne 'yes') {   
                             $inlinebuttons .= (<<ENDINLINE);  
 <tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr>  
 <tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr>  
 <tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr>  
 <tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr>  
 ENDINLINE  
                         }                          }
                     }                          if (&hidden_button_check() ne 'yes') { 
                 }      foreach my $row (6..9) {
    if ($inlineremote[${row}.'1'] ne ''
       || $inlineremote[$row.'2'] ne ''
       || $inlineremote[$row.'3'] ne '') {
       $inlinebuttons .= <<"ENDLINE";
   <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
   ENDLINE
    }
       }
    }
       }
    }
     }      }
     $result =(<<ENDREGTEXT);      $result =(<<ENDREGTEXT);
 <script type="text/javascript">  <script type="text/javascript">
 // BEGIN LON-CAPA Internal  // BEGIN LON-CAPA Internal
 </script>  </script>
 $timesync  $timesync
 $newmail  
 $tablestart  $tablestart
 $inlinebuttons  $inlinebuttons
 $tableend  $tableend
   $newmail
 <script type="text/javascript">  <script type="text/javascript">
 // END LON-CAPA Internal  // END LON-CAPA Internal
 </script>  </script>
Line 788  sub load_remote_msg { Line 815  sub load_remote_msg {
 <p>$link</p>  <p>$link</p>
 ENDREMOTEFORM  ENDREMOTEFORM
 }  }
   
   sub get_menu_name {
       my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
       $hostid =~ s/\W//g;
       return 'LCmenu'.$hostid;
   }
   
 # ================================================================= Reopen menu  # ================================================================= Reopen menu
   
 sub reopenmenu {  sub reopenmenu {
    if (($env{'browser.interface'} eq 'textual') ||     if (($env{'browser.interface'} eq 'textual') ||
        ($env{'environment.remote'} eq 'off')) { return ''; }         ($env{'environment.remote'} eq 'off')) { return ''; }
    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};     my $menuname = &get_menu_name();
    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
    return('window.open('.$nothing.',"'.$menuname.'","",false);');     return('window.open('.$nothing.',"'.$menuname.'","",false);');
 }   } 
Line 806  sub open { Line 840  sub open {
         ($env{'environment.remote'} eq 'off')) {           ($env{'environment.remote'} eq 'off')) { 
  return '<script type="text/javascript">self.name="loncapaclient";</script>';   return '<script type="text/javascript">self.name="loncapaclient";</script>';
     }      }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
           
 #    unless (shift eq 'unix') {  #    unless (shift eq 'unix') {
 # resizing does not work on linux because of virtual desktop sizes  # resizing does not work on linux because of virtual desktop sizes
Line 882  sub switch { Line 916  sub switch {
        my $text=$top.' '.$bot;         my $text=$top.' '.$bot;
        $text=~s/\s*\-\s*//gs;         $text=~s/\s*\-\s*//gs;
   
        my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};  
        if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }  
        my $pic=         my $pic=
    '<img alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.     '<img alt="'.$text.'" src="'.
    ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.     &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
    ($nobreak==3?'right':'left').'" />';     '" align="'.($nobreak==3?'right':'left').'" />';
        if ($env{'browser.interface'} eq 'faketextual') {         if ($env{'browser.interface'} eq 'faketextual') {
 # Accessibility  # Accessibility
    if ($nobreak==3) {     if ($nobreak==3) {
Line 936  sub secondlevel { Line 968  sub secondlevel {
 }  }
   
 sub openmenu {  sub openmenu {
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
     if (($env{'browser.interface'} eq 'textual') ||      if (($env{'browser.interface'} eq 'textual') ||
         ($env{'environment.remote'} eq 'off')) { return ''; }          ($env{'environment.remote'} eq 'off')) { return ''; }
     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();      my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
Line 986  sub rawconfig { Line 1018  sub rawconfig {
     my $uname=$env{'user.name'};      my $uname=$env{'user.name'};
     my $udom=$env{'user.domain'};      my $udom=$env{'user.domain'};
     my $adv=$env{'user.adv'};      my $adv=$env{'user.adv'};
       my $show_course=&show_course();
     my $author=$env{'user.author'};      my $author=$env{'user.author'};
     my $crs='';      my $crs='';
     if ($env{'request.course.id'}) {      if ($env{'request.course.id'}) {
Line 1025  sub rawconfig { Line 1058  sub rawconfig {
                $output.=&secondlevel(                 $output.=&secondlevel(
   $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);    $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
             }              }
    } elsif ($pro eq 'shc') {
               if ($show_course) {
                  $output.=&secondlevel(
             $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
               }
           } elsif ($pro eq 'nsc') {
               if (!$show_course) {
                  $output.=&secondlevel(
     $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
               }
         } elsif (($pro=~/^p(\w+)/) && ($prt)) {          } elsif (($pro=~/^p(\w+)/) && ($prt)) {
     if (&Apache::lonnet::allowed($1,$prt)) {      if (&Apache::lonnet::allowed($1,$prt)) {
                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
Line 1049  sub rawconfig { Line 1092  sub rawconfig {
         } elsif ($pro eq 'author') {          } elsif ($pro eq 'author') {
             if ($author) {              if ($author) {
                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||                  if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
                       (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {                      (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
                     # Check that we are on the correct machine                      # Check that we are on the correct machine
                     my $cadom=$requested_domain;                      my $cadom=$requested_domain;
                     my $caname=$env{'user.name'};                      my $caname=$env{'user.name'};
                     if ($prt eq 'rca') {                      if (($prt eq 'rca') || ($prt eq 'raa')) {
        ($cadom,$caname)=         ($cadom,$caname)=
                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);                                 ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
                     }                                             }                       
Line 1086  sub rawconfig { Line 1130  sub rawconfig {
 sub close {  sub close {
     if (($env{'browser.interface'} eq 'textual') ||      if (($env{'browser.interface'} eq 'textual') ||
         ($env{'environment.remote'} eq 'off')) { return ''; }          ($env{'environment.remote'} eq 'off')) { return ''; }
     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};      my $menuname = &get_menu_name();
     return(<<ENDCLOSE);      return(<<ENDCLOSE);
 <script type="text/javascript">  <script type="text/javascript">
 window.status='Accessing Remote Control';  window.status='Accessing Remote Control';
Line 1362  sub hidden_button_check { Line 1406  sub hidden_button_check {
     if ($env{'request.role.adv'}) {      if ($env{'request.role.adv'}) {
         return;          return;
     }      }
     return &Apache::lonnet::EXT('resource.0.buttonshide');       my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
       return $buttonshide; 
 }  }
   
 # ================================================================ Main Program  # ================================================================ Main Program

Removed from v.1.222  
changed lines
  Added in v.1.234


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