--- loncom/interface/lonmenu.pm 2013/05/13 20:37:58 1.369.2.41
+++ loncom/interface/lonmenu.pm 2013/08/08 02:24:02 1.369.2.44
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.41 2013/05/13 20:37:58 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.44 2013/08/08 02:24:02 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()
@@ -223,15 +224,16 @@ sub prep_menuitem {
. qq| href="$$menuitem[0]" target="_top">$link|;
}
-# 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 ''))) {
@@ -256,6 +258,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 '') {
@@ -275,9 +281,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 .= '
'.&mt($title).'';
+ $menu{$position} .= ''.&mt($title).'';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -288,19 +294,17 @@ sub primary_menu {
'helpdeskmail',
$defdom,$origmail);
if ($to ne '') {
- $menu .= &prep_menuitem($menuitem);
+ $menu{$position} .= &prep_menuitem($menuitem);
}
} else {
- $menu .= ''.&Apache::loncommon::top_nav_help('Help').'';
+ $menu{$position} .= ''.&Apache::loncommon::top_nav_help('Help').'';
}
} 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 "";
+ return ("",
+ "");
}
#returns hashref {user=>'',dom=>''} containing:
@@ -337,6 +341,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);
@@ -428,7 +435,7 @@ sub secondary_menu {
} else {
$link = '#';
}
- my @scndsub;
+ my @scndsub;
if (ref($secondary_submenu{$title}) eq 'ARRAY') {
foreach my $item (@{$secondary_submenu{$title}}) {
if (ref($item) eq 'ARRAY') {
@@ -510,9 +517,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 = ''.
- ''.
- ''.&mt($title).
+ ''.
+ ''.$name.
''.
' ▼'.
'';
@@ -521,12 +538,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 .= '- '.
+ $borderbot.'">'.
&mt($item->[1]).'
';
}
}
@@ -1391,7 +1414,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&recname=$sname&recdom=$sdom')",
'Send message to specific user','','',1);
}
my $hideprivileged = 1;
@@ -1413,13 +1436,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&origin=aboutme&uname=$sname&udom=$sdom')",
'Slot reservation history','','',1);
}
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&recname=$sname&recdom=$sdom')",
'Add records','','',1);
}
}
@@ -1435,7 +1458,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&forcesupplement=1&supppath=$esc_path'",
'Folder/Page Content','','',1);
}
}
@@ -2630,7 +2653,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];