Diff for /loncom/interface/lonmenu.pm between versions 1.246 and 1.258

version 1.246, 2008/12/04 08:56:28 version 1.258, 2009/04/14 23:52:11
Line 174  sub initlittle { Line 174  sub initlittle {
                                                     'Courses':'Roles'),                                                      'Courses':'Roles'),
                                        'other' => 'Other Roles',                                         'other' => 'Other Roles',
                                        'docs' => 'Edit Course',                                         'docs' => 'Edit Course',
                                        'exit' => 'Exit',                                         'exit' => 'Logout',
                                        'login' => 'Log In',                                         'login' => 'Log In',
        'launch' => 'Launch Remote Control',         'launch' => 'Launch Remote Control',
                                        'groups' => 'Groups',                                         'groups' => 'Groups',
Line 206  sub menubuttons { Line 206  sub menubuttons {
     my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));      my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
   
     my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");      my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
     $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.      $logo = '<a href="/adm/about.html"><img src="'.
  $logo.'" alt="LON-CAPA Logo" /></a></td>';   $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
   
     if ($env{'request.state'} eq 'construct') {      if ($env{'request.state'} eq 'construct') {
         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {          if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
Line 292  ENDMAINMENU Line 292  ENDMAINMENU
     return (<<ENDINLINEMENU);      return (<<ENDINLINEMENU);
    <table id="LC_top_nav">     <table id="LC_top_nav">
     <tr>      <tr>
       $logo        <td>$logo</td>
       <td></td>        <td></td>
       <td class="LC_top_nav_login">        <td class="LC_top_nav_login">
         <a href="/adm/roles" target="_top">$lt{'login'}</a>          <a href="/adm/roles" target="_top">$lt{'login'}</a>
Line 301  ENDMAINMENU Line 301  ENDMAINMENU
   </table>    </table>
 ENDINLINEMENU  ENDINLINEMENU
         }          }
         $roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>';          $roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
 # Do we have a NAV link?  # Do we have a NAV link?
         if ($env{'request.course.id'}) {          if ($env{'request.course.id'}) {
     my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.      my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.
Line 310  ENDINLINEMENU Line 310  ENDINLINEMENU
  $link="javascript:gonav('".$link."')";   $link="javascript:gonav('".$link."')";
     }      }
     $navmaps=(<<ENDNAV);      $navmaps=(<<ENDNAV);
 <td><a href="$link" target="_top">$lt{'nav'}</a></td>  <li><a href="$link" target="_top">$lt{'nav'}</a></li>
 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);
 <td><a href="/adm/coursedocs" target="_top">$text</a></td>  <li><a href="/adm/coursedocs" target="_top">$text</a></li>
 ENDDOCS  ENDDOCS
             }              }
             if ($showgroups) {              if ($showgroups) {
                 $groups =(<<ENDGROUPS);                  $groups =(<<ENDGROUPS);
 <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>  <li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li>
 ENDGROUPS  ENDGROUPS
             }              }
     if (&show_return_link()) {      if (&show_return_link()) {
                 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>  <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
 ENDRELOAD  ENDRELOAD
             }              }
             if ($role_selector) {              if ($role_selector) {
                 $roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';              #$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
    $role_selector = '<li>'.$role_selector.'</li>';
             }              }
         }          }
  if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {   if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
     my $escreload=&escape('return:');      my $escreload=&escape('return:');
     $reloadlink=(<<ENDCRELOAD);      $reloadlink=(<<ENDCRELOAD);
 <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>  <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
 ENDCRELOAD  ENDCRELOAD
         }          }
         my $reg='';          my $reg='';
Line 347  ENDCRELOAD Line 348  ENDCRELOAD
         my $form=&serverform();          my $form=&serverform();
  my $utility=&utilityfunctions();   my $utility=&utilityfunctions();
   
    my $messagelink = "";
    if(&Apache::lonmsg::mynewmail()){
    $messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message(new)</a>'
    }else{
    $messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message</a>'
    }
         my $helplink=&Apache::loncommon::top_nav_help('Help');          my $helplink=&Apache::loncommon::top_nav_help('Help');
  return (<<ENDINLINEMENU);   return (<<ENDINLINEMENU);
 <script type="text/javascript">  <script type="text/javascript">
Line 355  ENDCRELOAD Line 362  ENDCRELOAD
 $utility  $utility
 // ]]>  // ]]>
 </script>  </script>
 <table id="LC_top_nav">  <ol class="LC_smallMenu LC_right">
 <tr>   <li>$logo</li>
 $logo   <li>$messagelink</li>
 <td><a href="/adm/menu" target="_top">$lt{'main'}</a></td>   <li>$roles</li>
    <li>$helplink</li>
    <li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li>
   </ol>
   <ol id="LC_TabMainMenuContent">
   <li><a href="/adm/menu" target="_top">$lt{'main'}</a></li>
 $reloadlink  $reloadlink
 $navmaps  $navmaps
 $docs  $docs
 $groups  $groups
 $roles  $role_selector
 <td style="width: 2.0em;">$helplink</td>  </ol>
 <td style="width: 2.0em;"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>  
 </tr>  
 </table>  
 $form  $form
 <script type="text/javascript">  <script type="text/javascript">
 // END LON-CAPA Internal  // END LON-CAPA Internal
 </script>  </script>
   <br clear="all" />
 $reg  $reg
 ENDINLINEMENU  ENDINLINEMENU
     } else {      } else {
Line 513  sub innerregister { Line 523  sub innerregister {
         ### resource          ### resource
         ###          ###
         my $editbutton = '';          my $editbutton = '';
           my $noeditbutton = 1;
           my ($cnum,$cdom);
           if ($env{'request.course.id'}) {
               $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
               $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           }
         if ($env{'user.author'}) {          if ($env{'user.author'}) {
             if ($env{'request.role'}=~/^(aa|ca|au)/) {              if ($env{'request.role'}=~/^(aa|ca|au)/) {
                 # Set defaults for authors                  # Set defaults for authors
Line 540  sub innerregister { Line 556  sub innerregister {
  foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }   foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  if (!$allowed) {   if (!$allowed) {
     $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);      $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
                       $noeditbutton = 0;
                 }                  }
             }              }
             ##              ##
Line 548  sub innerregister { Line 565  sub innerregister {
             my $cfile='';              my $cfile='';
             my $cfuname='';              my $cfuname='';
             my $cfudom='';              my $cfudom='';
               my $uploaded;
             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/;                  if (defined($cnum) && defined($cdom)) {
                 # Check that the user has permission to edit this resource                      $uploaded = &is_course_upload($file,$cnum,$cdom);
                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);                  }
                 if (defined($cfudom)) {                  if (!$uploaded) {
     my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);                      $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
     my $allowed=0;                      # Check that the user has permission to edit this resource
     my @ids=&Apache::lonnet::current_machine_ids();                      ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }                      if (defined($cfudom)) {
     if ($allowed) {          my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
                         $cfile=$file;          my $allowed=0;
           my @ids=&Apache::lonnet::current_machine_ids();
           foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
           if ($allowed) {
                               $cfile=$file;
                           }
                     }                      }
                 }                  }
             }                      }
             # Finally, turn the button on or off              # Finally, turn the button on or off
             if ($cfile && !$const_space) {              if ($cfile && !$const_space) {
                 $editbutton=&switch                  $editbutton=&switch
                     ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',                      ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
                      "go('".$cfile."');","Edit this resource");                       "go('".$cfile."');","Edit this resource");
                   $noeditbutton = 0;
             } elsif ($editbutton eq '') {              } elsif ($editbutton eq '') {
                 $editbutton=&clear(6,1);                  $editbutton=&clear(6,1);
             }              }
         }          }
           if (($noeditbutton) && ($env{'request.filename'})) { 
               if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                   my $file=&Apache::lonnet::declutter($env{'request.filename'});
                   if (defined($cnum) && defined($cdom)) {
                       if (&is_course_upload($file,$cnum,$cdom)) {
                           my $cfile = &edit_course_upload($file,$cnum,$cdom);
                           if ($cfile) {
                               $editbutton=&switch
                                           ('','',6,1,'pcstr.gif','edit[_1]',
                                            'resource[_2]',"go('".$cfile."');",
                                            'Edit this resource');
                           }
                       }
                   }
               }
           }
         ###          ###
         ###          ###
 # Prepare the rest of the buttons  # Prepare the rest of the buttons
Line 622  $menuitems.="Make notes and annotations Line 662  $menuitems.="Make notes and annotations
             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {              unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
  if (!$env{'request.enc'}) {   if (!$env{'request.enc'}) {
     $menuitems.=(<<ENDREALRES);      $menuitems.=(<<ENDREALRES);
 s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information  s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show Metadata
 ENDREALRES  ENDREALRES
                 }                  }
         $menuitems.=(<<ENDREALRES);          $menuitems.=(<<ENDREALRES);
Line 806  ENDDONOTREGTHIS Line 846  ENDDONOTREGTHIS
     return $result;      return $result;
 }  }
   
   sub is_course_upload {
       my ($file,$cnum,$cdom) = @_;
       my $uploadpath = &LONCAPA::propath($cdom,$cnum);
       $uploadpath =~ s{^\/}{};
       if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
           ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
           return 1;
       }
       return;
   }
   
   sub edit_course_upload {
       my ($file,$cnum,$cdom) = @_;
       my $cfile;
       if ($file =~/\.(htm|html|css|js|txt)$/) {
           my $ext = $1;
           my $url = &Apache::lonnet::hreflocation('',$file);
           my $home = &Apache::lonnet::homeserver($cnum,$cdom);
           my @ids=&Apache::lonnet::current_machine_ids();
           my $dest;
           if ($home && grep(/^\Q$home\E$/,@ids)) {
               $dest = $url.'?forceedit=1';
           } else {
               unless (&Apache::lonnet::get_locks()) {
                   $dest = '/adm/switchserver?otherserver='.
                           $home.'&role='.$env{'request.role'}.
                           '&url='.$url.'&forceedit=1';
               }
           }
           if ($dest) {
               $cfile = &HTML::Entities::encode($dest,'"<>&');
           }
       }
       return $cfile;
   }
   
 sub loadevents() {  sub loadevents() {
     if ($env{'request.state'} eq 'construct' ||      if ($env{'request.state'} eq 'construct' ||
  $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }   $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
Line 1027  sub switch { Line 1103  sub switch {
        my $pic=         my $pic=
    '<img alt="'.$text.'" src="'.     '<img alt="'.$text.'" src="'.
    &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).     &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
    '" align="'.($nobreak==3?'right':'left').'" />';     '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
        if ($env{'browser.interface'} eq 'faketextual') {         if ($env{'browser.interface'} eq 'faketextual') {
 # Accessibility  # Accessibility
    if ($nobreak==3) {     if ($nobreak==3) {
        $inlineremote[$idx]="\n".         $inlineremote[$idx]="\n".
    '<td class="LC_menubuttons_text" align="right">'.$text.     '<td class="LC_menubuttons_text" align="right">'.$text.
    '</td><td class="LC_menubuttons_img" align="left">'.     '</td><td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';     '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
    } elsif ($nobreak) {     } elsif ($nobreak) {
        $inlineremote[$idx]="\n<tr>".         $inlineremote[$idx]="\n<tr>".
    '<td class="LC_menubuttons_img" align="left">'.     '<td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.'</a></td>     '<a href="javascript:'.$act.';">'.$pic.'</a></td>
                     <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';                      <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';
    } else {     } else {
        $inlineremote[$idx]="\n<tr>".         $inlineremote[$idx]="\n<tr>".
    '<td class="LC_menubuttons_img" align="left">'.     '<td align="left">'.
    '<a href="javascript:'.$act.';">'.$pic.     '<a href="javascript:'.$act.';">'.$pic.
    '</a></td><td class="LC_menubuttons_text" colspan="3">'.     '</a></td><td class="LC_menubuttons_text" colspan="3">'.
    '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';     '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
Line 1093  sub inlinemenu { Line 1169  sub inlinemenu {
         for (my $row=1; $row<=8; $row++) {          for (my $row=1; $row<=8; $row++) {
             foreach my $cat (keys(%category_members)) {              foreach my $cat (keys(%category_members)) {
                if ($category_positions{$cat} ne "$col,$row") { next; }                 if ($category_positions{$cat} ne "$col,$row") { next; }
                #$output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';                 #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
                $output.='<div class="ContentBoxSpecial">';                 $output.='<div class="LC_ContentBoxSpecial">';
        $output.='<h4 class="hcell">'.&mt($category_names{$cat}).'</h4>';         $output.='<h4 class="LC_hcell">'.&mt($category_names{$cat}).'</h4>';
                $output.='<table id="LC_menubuttons_mainmenu">';                 $output.='<table>';
                my %active=();                 my %active=();
                foreach my $menu_item (split(/\:/,$category_members{$cat})) {                 foreach my $menu_item (split(/\:/,$category_members{$cat})) {
                   if ($inlineremote[$menu_item]) {                    if ($inlineremote[$menu_item]) {
Line 1105  sub inlinemenu { Line 1181  sub inlinemenu {
                }                   }  
                foreach my $item (sort(keys(%active))) {                 foreach my $item (sort(keys(%active))) {
                   $output.=$inlineremote[$item];                    $output.=$inlineremote[$item];
  &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]");  
                }                 }
                $output.='</table>';                 $output.='</table>';
                $output.='</div>';                 $output.='</div>';
Line 1225  sub rawconfig { Line 1300  sub rawconfig {
                     }                      }
                 }                  }
             }              }
           } elsif ($pro eq 'tools') {
               my @tools = ('aboutme','blog','portfolio');
               if (grep(/^\Q$prt\E$/,@tools)) {
                   if (!&Apache::lonnet::usertools_access($env{'user.name'},
                                                          $env{'user.domain'},
                                                          $prt,undef,'tools')) {
                       $output.=&clear($row,$col);
                       next;
                   }
               } elsif ($prt eq 'reqcrs') {
                   my $showreqcrs = 0;
                   foreach my $type ('official','unofficial') {
                       if (&Apache::lonnet::usertools_access($env{'user.name'},
                                                       $env{'user.domain'},
                                                       $type,undef,'requestcourses')) {
                           $showreqcrs = 1;
                           last;
                       }
                   }
                   if (!$showreqcrs) {
                       $output.=&clear($row,$col);
                       next;
                   }
               }
               $prt='any';
               $output.=&secondlevel(
             $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
         }          }
     }      }
     unless (($env{'browser.interface'} eq 'textual') ||      unless (($env{'browser.interface'} eq 'textual') ||
Line 1448  function set_bookmark() { Line 1550  function set_bookmark() {
    +"type='text' name='title' size=45 value='"+clienttitle+"' />"     +"type='text' name='title' size=45 value='"+clienttitle+"' />"
    +"<br />Address:<br /><input type='text' name='address' size='45' "     +"<br />Address:<br /><input type='text' name='address' size='45' "
    +"value='"+clienthref+"' /><br /><center><input type='submit' "     +"value='"+clienthref+"' /><br /><center><input type='submit' "
    +"value='Save' /> <input type='button' value='Close (no save)' "     +"value='Save' /> <input type='button' value='Close' "
    +"onclick='javascript:window.close();' /><\\/center><\\/td>"     +"onclick='javascript:window.close();' /><\\/center><\\/td>"
    +"<\\/tr><\\/table><\\/form><\\/center>"     +"<\\/tr><\\/table><\\/form><\\/center>"
    +'$end_page_bookmark' );     +'$end_page_bookmark' );

Removed from v.1.246  
changed lines
  Added in v.1.258


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.