--- loncom/interface/lonmenu.pm	2013/05/09 05:24:36	1.414
+++ loncom/interface/lonmenu.pm	2013/08/06 16:02:31	1.418
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.414 2013/05/09 05:24:36 raeburn Exp $
+# $Id: lonmenu.pm,v 1.418 2013/08/06 16:02:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,10 +106,11 @@ secondary_menu().
 
 =item primary_menu()
 
-This routine evaluates @primary_menu and returns XHTML for the menu
-that contains following links: About, Message, Roles, Help, Logout
+This routine evaluates @primary_menu and returns a two item array, 
+with the array elements containing XHTML for the left and right sides of 
+the menu that contains the following links: About, Message, Roles, Help, Logout 
 @primary_menu is filled within the BEGIN block of this module with 
-entries from mydesk.tab 
+entries from mydesk.tab
 
 =item secondary_menu()
 
@@ -203,15 +204,16 @@ sub prep_menuitem {
            . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
 }
 
-# primary_menu() evaluates @primary_menu and returns XHTML for the menu
-# that contains following links:
-# About, Message, Personal, Roles, Help, Logout
+# primary_menu() evaluates @primary_menu and returns a two item array,
+# with the array elements containing XHTML for the left and right sides of 
+# the menu that contains the following links:
+# Personal, About, Message, Roles, Help, Logout
 # @primary_menu is filled within the BEGIN block of this module with 
 # entries from mydesk.tab
 sub primary_menu {
-    my $menu;
+    my (%menu);
     # each element of @primary contains following array:
-    # (link url, icon path, alt text, link text, condition)
+    # (link url, icon path, alt text, link text, condition, position)
     my $public;
     if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
         || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
@@ -236,6 +238,10 @@ sub primary_menu {
                 && !&Apache::loncommon::show_course(); ##
         
         my $title = $menuitem->[3];
+        my $position = $menuitem->[5];
+        if ($position eq '') {
+            $position = 'right';
+        }
         if (defined($primary_submenu{$title})) {
             my ($link,$target);
             if ($menuitem->[0] ne '') {
@@ -255,9 +261,9 @@ sub primary_menu {
                     push(@primsub,$item);
                 }
                 if (@primsub > 0) {
-                    $menu .= &create_submenu($link,$target,$title,\@primsub);
+                    $menu{$position} .= &create_submenu($link,$target,$title,\@primsub);
                 } elsif ($link) {
-                    $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
+                    $menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
                 }
             }
         } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -268,19 +274,17 @@ sub primary_menu {
                                                                   'helpdeskmail',
                                                                   $defdom,$origmail);
                 if ($to ne '') {
-                    $menu .= &prep_menuitem($menuitem); 
+                    $menu{$position} .= &prep_menuitem($menuitem); 
                 }
             } else {
-                $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
+                $menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
             }
         } else {
-            $menu .= prep_menuitem($menuitem);
+            $menu{$position} .= prep_menuitem($menuitem);
         }
     }
-    $menu =~ s/\[domain\]/$env{'user.domain'}/g;
-    $menu =~ s/\[user\]/$env{'user.name'}/g;
-
-    return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
+    return ("<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>",
+            "<ol class=\"LC_primary_menu LC_floatright LC_right\">$menu{'right'}</ol>");
 }
 
 #returns hashref {user=>'',dom=>''} containing:
@@ -317,6 +321,9 @@ sub secondary_menu {
                                                : '');
     my $canedit       = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
     my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
+    if ($canviewroster eq 'disabled') {
+        undef($canviewroster);
+    }
     my $canviewgrps   = &Apache::lonnet::allowed('vcg', $crs_sec); 
     my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); 
     my $canviewwnew   = &Apache::lonnet::allowed('whn', $crs_sec); 
@@ -325,7 +332,7 @@ sub secondary_menu {
     my $canmgr        = &Apache::lonnet::allowed('mgr', $crs_sec); 
     my $author        = &getauthor();
 
-    my ($cdom,$cnum,$showsyllabus,$showfeeds);
+    my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv);
     if ($env{'request.course.id'}) {
         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -345,6 +352,12 @@ sub secondary_menu {
                 $showfeeds = 1;
             }
         }
+        unless ($canmgr) {
+            my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
+            if (keys(%slots) > 0) {
+                $showresv = 1;
+            }
+        }
     }
 
     my ($canmodifycoauthor); 
@@ -381,8 +394,8 @@ sub secondary_menu {
                 && ($canmodifyuser || !$canviewroster);
         next if    $$menuitem[4]   eq 'mgr'
                 && !$canmgr;
-        next if    $$menuitem[4]   eq 'nmgr'
-                && $canmgr;
+        next if    $$menuitem[4]   eq 'showresv'
+                && !$showresv;
         next if    $$menuitem[4]   eq 'whn'
                 && !$canviewwnew;
         next if    $$menuitem[4]   eq 'opa'
@@ -462,9 +475,19 @@ sub create_submenu {
     if ($target ne '') {
         $disptarget = ' target="'.$target.'"';
     }
+    my $name;
+    if ($title eq 'Personal') {
+        if ($env{'user.name'} && $env{'user.domain'}) {
+            $name = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+        } else {
+            $name = &mt($title);
+        }
+    } else {
+        $name = &mt($title);
+    }
     my $menu = '<li class="LC_hoverable">'.
                '<a href="'.$link.'"'.$disptarget.'>'.
-               '<span class="LC_nobreak">'.&mt($title).
+               '<span class="LC_nobreak">'.$name.
                '<span class="LC_fontsize_small" style="font-weight:normal;">'.
                ' &#9660;</span></span></a>'.
                '<ul>';
@@ -473,12 +496,18 @@ sub create_submenu {
     foreach my $item (@{$submenu}) {
         $count ++;
         if (ref($item) eq 'ARRAY') {
+            my $href = $item->[0];
+            if ($href =~ /(aboutme|rss\.html)$/) {
+                next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne ''));
+                $href =~ s/\[domain\]/$env{'user.domain'}/g;
+                $href =~ s/\[user\]/$env{'user.name'}/g;
+            }
             my $borderbot;
             if ($count == $numsub) {
                 $borderbot = 'border-bottom:1px solid black;';
             }
             $menu .= '<li style="margin:0;padding:0;'.
-                     $borderbot.'"><a href="'.$item->[0].'">'.
+                     $borderbot.'"><a href="'.$href.'">'.
                      &mt($item->[1]).'</a></li>';
         }
     }
@@ -947,7 +976,7 @@ sub prepare_functions {
             unless (&Apache::lonnet::is_course($sdom,$sname)) {
                 &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
                         '',
-                        "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
+                        "go('/adm/email?compose=individual&amp;recname=$sname&amp;recdom=$sdom')",
                             'Send message to specific user');
             }
             my $hideprivileged = 1;
@@ -969,13 +998,13 @@ sub prepare_functions {
                 if ($perms{'vgr'}) {
                     &switch('','',6,6,'rsrv-22x22.png','Reservations',
                             '',
-                            "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
+                            "go('/adm/slotrequest?command=showresv&amp;origin=aboutme&amp;uname=$sname&amp;udom=$sdom')",
                             'Slot reservation history');
                 }
                 if ($perms{'srm'}) {
                     &switch('','',6,7,'contact-new-22x22.png','Records',
                             '',
-                            "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
+                            "go('/adm/email?recordftf=retrieve&amp;recname=$sname&amp;recdom=$sdom')",
                             'Add records');
                 }
             }
@@ -991,7 +1020,7 @@ sub prepare_functions {
             if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
                 my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
                 &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
-                        "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+                        "location.href='/adm/coursedocs?command=direct&amp;forcesupplement=1&amp;supppath=$esc_path'",
                         'Folder/Page Content');
             }
         }
@@ -2100,7 +2129,7 @@ BEGIN {
                         $category_positions{$entries[2]}=$entries[1];
                         $category_names{$entries[2]}=$entries[3];
                     } elsif ($configline=~/^prim\:/) {
-                        my @entries = (split(/\:/, $configline))[1..5];
+                        my @entries = (split(/\:/, $configline))[1..6];
                         push(@primary_menu,\@entries);
                     } elsif ($configline=~/^primsub\:/) {
                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];