--- loncom/interface/lonmenu.pm	2008/09/11 13:30:59	1.242
+++ loncom/interface/lonmenu.pm	2008/12/09 04:49:01	1.249
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.242 2008/09/11 13:30:59 raeburn Exp $
+# $Id: lonmenu.pm,v 1.249 2008/12/09 04:49:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,105 @@
 # browser.interface is 'textual'
 #
 
+=head1 NAME
+
+Apache::lonmenu
+
+=head1 SYNOPSIS
+
+Coordinates the response to clicking an image.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=item show_course()
+
+Little texts
+
+=item initlittle()
+
+=item menubuttons()
+
+This gets called at the top of the body section
+
+=item show_return_link()
+
+=item registerurl()
+
+This gets called in the header section
+
+=item innerregister()
+
+This gets called in order to register a URL, both with the Remote
+and in the body of the document
+
+=item loadevents()
+
+=item unloadevents()
+
+=item startupremote()
+
+=item setflags()
+
+=item maincall()
+
+=item load_remote_msg()
+
+=item get_menu_name()
+
+=item reopenmenu()
+
+=item open()
+
+Open the menu
+
+=item clear()
+
+=item switch()
+
+Switch a button or create a link
+Switch acts on the javascript that is executed when a button is clicked.  
+The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
+
+=item secondlevel()
+
+=item openmenu()
+
+=item inlinemenu()
+
+=item rawconfig()
+
+=item close()
+
+=item footer()
+
+=item utilityfunctions()
+
+=item serverform()
+
+=item constspaceform()
+
+=item get_nav_status()
+
+=item convert_menu_function()
+
+FIXME this needs to move into mydesktab and the other locations 
+the text is generated
+
+=item hidden_button_check()
+
+=item roles_selector()
+
+=item jump_to_role()
+
+=back
+
+=cut
+
 package Apache::lonmenu;
 
 use strict;
@@ -53,7 +152,6 @@ my @inlineremote;
 
 
 
-# ================================================================ Little texts
 sub show_course {
     my $course = !$env{'user.adv'};
     if (!$env{'user.adv'}) {
@@ -84,8 +182,6 @@ sub initlittle {
                                        );
 }
 
-# ============================= This gets called at the top of the body section
-
 sub menubuttons {
     my $forcereg=shift;
     my $registration=shift;
@@ -111,7 +207,7 @@ sub menubuttons {
 
     my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
     $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.
-	$logo.'" alt="LON-CAPA Logo" /></a></td>';
+	$logo.'" alt="LON-CAPA Logo" class="noBorder" /></a></td>';
 
     if ($env{'request.state'} eq 'construct') {
         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
@@ -203,7 +299,6 @@ ENDMAINMENU
      </td>
     </tr>
   </table>
-</font>
 ENDINLINEMENU
         }
         $roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>';
@@ -269,8 +364,8 @@ $navmaps
 $docs
 $groups
 $roles
-<td class="LC_top_nav_help">$helplink</td>
-<td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
+<td style="width: 2.0em;">$helplink</td>
+<td style="width: 2.0em;"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
 </tr>
 </table>
 $form
@@ -297,7 +392,6 @@ sub show_return_link {
 	     ));
 }
 
-# ====================================== This gets called in the header section
 
 sub registerurl {
     my ($forcereg) = @_;
@@ -322,9 +416,6 @@ sub registerurl {
     return $result.$force_title;
 }
 
-# =========== This gets called in order to register a URL, both with the Remote
-# =========== and in the body of the document
-
 sub innerregister {
     my ($forcereg, $titletable) = @_;
     my $result = '';
@@ -514,9 +605,20 @@ c&8&1
 c&8&2
 s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
 s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
-s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
 ENDMENUITEMS
 
+my $currentURL = &Apache::loncommon::get_symb();
+my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
+my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
+$menuitems.="s&9&3&";
+if(length($annotation) > 0){
+	$menuitems.="anot2.gif";
+}else{
+	$menuitems.="anot.gif";
+}
+$menuitems.="&anno-[_1]&tations[_1]&annotate()&";
+$menuitems.="Make notes and annotations about this resource&&1\n";
+
             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
 		if (!$env{'request.enc'}) {
 		    $menuitems.=(<<ENDREALRES);
@@ -716,7 +818,6 @@ sub unloadevents() {
     return 'LONCAPAstale();';
 }
 
-# ============================================================= Start up remote
 
 sub startupremote {
     my ($lowerurl)=@_;
@@ -830,7 +931,6 @@ sub get_menu_name {
     return 'LCmenu'.$hostid;
 }
 
-# ================================================================= Reopen menu
 
 sub reopenmenu {
    if (($env{'browser.interface'} eq 'textual') ||
@@ -840,7 +940,6 @@ sub reopenmenu {
    return('window.open('.$nothing.',"'.$menuname.'","",false);');
 } 
 
-# =============================================================== Open the menu
 
 sub open {
     my $returnval='';
@@ -928,22 +1027,22 @@ sub switch {
        my $pic=
 	   '<img alt="'.$text.'" src="'.
 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
-	   '" align="'.($nobreak==3?'right':'left').'" />';
+	   '" align="'.($nobreak==3?'right':'left').'" class="noBorder" />';
        if ($env{'browser.interface'} eq 'faketextual') {
 # Accessibility
 	   if ($nobreak==3) {
 	       $inlineremote[$idx]="\n".
 		   '<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>';
 	   } elsif ($nobreak) {
 	       $inlineremote[$idx]="\n<tr>".
-		   '<td class="LC_menubuttons_img" align="left">'.
+		   '<td align="left">'.
 		   '<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>';
 	   } else {
 	       $inlineremote[$idx]="\n<tr>".
-		   '<td class="LC_menubuttons_img" align="left">'.
+		   '<td align="left">'.
 		   '<a href="javascript:'.$act.';">'.$pic.
 		   '</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>';
@@ -994,10 +1093,10 @@ sub inlinemenu {
         for (my $row=1; $row<=8; $row++) {
             foreach my $cat (keys(%category_members)) {
                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.='<fieldset id="LC_mainmenu_fieldset">';
-	       $output.='<legend class="LC_mainmenu_fieldset_category">'.&mt($category_names{$cat}).'</legend>';
-               $output.='<table id="LC_menubuttons_mainmenu">';
+               #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
+               $output.='<div class="ContentBoxSpecial">';
+	       $output.='<h4 class="hcell">'.&mt($category_names{$cat}).'</h4>';
+               $output.='<table>';
                my %active=();
                foreach my $menu_item (split(/\:/,$category_members{$cat})) {
                   if ($inlineremote[$menu_item]) {
@@ -1006,10 +1105,9 @@ sub inlinemenu {
                }  
                foreach my $item (sort(keys(%active))) {
                   $output.=$inlineremote[$item];
-		&Apache::lonnet::logthis("item=$item output=$inlineremote[$item]");
                }
                $output.='</table>';
-               $output.='</fieldset>';
+               $output.='</div>';
             }
          }
          $output.="</td>";
@@ -1126,6 +1224,18 @@ 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)) {
+                    $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') ||