--- loncom/interface/lonmenu.pm 2013/05/09 05:24:36 1.414
+++ loncom/interface/lonmenu.pm 2014/12/20 15:35:40 1.430
@@ -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.430 2014/12/20 15:35:40 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|;
}
-# 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,1);
} elsif ($link) {
- $menu .= '
'.&mt($title).'';
+ $menu{$position} .= ''.&mt($title).'';
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
@@ -268,19 +274,23 @@ 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 "";
+ my @output = ('','');
+ if ($menu{'left'} ne '') {
+ $output[0] = "";
+ }
+ if ($menu{'right'} ne '') {
+ $output[1] = "";
+ }
+ return @output;
}
#returns hashref {user=>'',dom=>''} containing:
@@ -309,6 +319,7 @@ sub getauthor{
}
sub secondary_menu {
+ my ($httphost) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -317,6 +328,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 +339,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 +359,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 +401,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'
@@ -404,7 +424,8 @@ sub secondary_menu {
($roleswitcher_js,$roleswitcher_form,my $switcher) =
&roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'}
+ $env{'course.' . $env{'request.course.id'} . '.num'},
+ $httphost
);
$menu .= $switcher;
} else {
@@ -456,15 +477,25 @@ sub secondary_menu {
}
sub create_submenu {
- my ($link,$target,$title,$submenu) = @_;
+ my ($link,$target,$title,$submenu,$translate) = @_;
return unless (ref($submenu) eq 'ARRAY');
my $disptarget;
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.
''.
' ▼'.
'';
@@ -473,13 +504,27 @@ 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;';
}
+ unless (($href eq '') || ($href =~ /^\#/)) {
+ $target = ' target="_top"';
+ }
$menu .= '- '.
- &mt($item->[1]).'
';
+ $borderbot.'">';
+ if ($translate) {
+ $menu .= &mt($item->[1]);
+ } else {
+ $menu .= $item->[1];
+ }
+ $menu .= '
';
}
}
$menu .= '';
@@ -707,7 +752,7 @@ ENDMENUITEMS
# wishlist is only available for users with access to resource-pool
# and links can only be set for resources within the resource-pool
$menuitems .= (< 0){
}
$menuitems.="&Notes&&annotate()&";
$menuitems.="Make notes and annotations about this resource&&1\n";
+my $is_mobile;
+if ($env{'browser.mobile'}) {
+ $is_mobile = 1;
+}
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
$menuitems.=(< 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');
}
}
@@ -1181,7 +1233,10 @@ sub rawconfig {
my $pub=($env{'request.state'} eq 'published');
my $con=($env{'request.state'} eq 'construct');
my $rol=$env{'request.role'};
- my $requested_domain = $env{'request.role.domain'};
+ my $requested_domain;
+ if ($rol) {
+ $requested_domain = $env{'request.role.domain'};
+ }
foreach my $line (@desklines) {
my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
$prt=~s/\$uname/$uname/g;
@@ -1195,7 +1250,13 @@ sub rawconfig {
next if ($crstype ne 'Community');
$prt=~s/\$cmty/$crs/g;
}
- $prt=~s/\$requested_domain/$requested_domain/g;
+ if ($prt =~ m/\$requested_domain/) {
+ if ((!$requested_domain) && ($pro eq 'pbre') && ($env{'user.adv'})) {
+ $prt=~s/\$requested_domain/$env{'user.domain'}/g;
+ } else {
+ $prt=~s/\$requested_domain/$requested_domain/g;
+ }
+ }
if ($category_names{$cat}!~/\w/) { $cat='oth'; }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
@@ -1231,8 +1292,9 @@ sub rawconfig {
next;
}
}
- if (&Apache::lonnet::allowed($priv,$prt)) {
- $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
+ (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro eq 'course') {
if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
@@ -1342,7 +1404,7 @@ sub rawconfig {
sub check_for_rcrs {
my $showreqcrs = 0;
- my @reqtypes = ('official','unofficial','community');
+ my @reqtypes = ('official','unofficial','community','textbook');
foreach my $type (@reqtypes) {
if (&Apache::lonnet::usertools_access($env{'user.name'},
$env{'user.domain'},
@@ -1409,6 +1471,7 @@ END
}
sub utilityfunctions {
+ my ($httphost) = @_;
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
if ($currenturl =~ m{^/adm/wrapper/ext/}
&& $env{'request.external.querystring'} ) {
@@ -1443,8 +1506,26 @@ sub utilityfunctions {
my $countdown = &countdown_toggle_js();
-return (<'."\n".
+ '