--- loncom/interface/lonmenu.pm 2012/05/21 16:25:37 1.369.2.4
+++ loncom/interface/lonmenu.pm 2012/05/23 00:29:22 1.369.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.4 2012/05/21 16:25:37 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.5 2012/05/23 00:29:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -166,7 +166,7 @@ use LONCAPA qw(:DEFAULT :match);
use HTML::Entities();
use vars qw(@desklines %category_names %category_members %category_positions
- $readdesk @primary_menu %primary_submenu @secondary_menu);
+ $readdesk @primary_menu %primary_submenu @secondary_menu %secondary_submenu);
my @inlineremote;
@@ -234,7 +234,7 @@ sub primary_menu {
$title =
''.$title.
''.
- '▼';
+ ' ▼';
}
}
$menu .= '
'.
@@ -322,12 +322,13 @@ sub secondary_menu {
? "/$env{'request.course.sec'}"
: '');
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
- my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
- my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
- my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
+ my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
+ my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
+ my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
+ my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
- my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
+ my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
my $author = &getauthor();
my %groups = &Apache::lonnet::get_active_groups(
@@ -343,6 +344,10 @@ sub secondary_menu {
&& !$env{'request.course.id'};
next if $$menuitem[4] =~ /^mdc/
&& !$canedit;
+ next if $$menuitem[4] eq 'mdcCourse'
+ && ($crstype eq 'Community');
+ next if $$menuitem[4] eq 'mdcCommunity'
+ && ($crstype eq 'Course');
next if $$menuitem[4] eq 'nvgr'
&& $canvgr;
next if $$menuitem[4] eq 'vgr'
@@ -350,7 +355,7 @@ sub secondary_menu {
next if $$menuitem[4] eq 'cst'
&& !$canmodifyuser;
next if $$menuitem[4] eq 'ncst'
- && $canmodifyuser;
+ && ($canmodifyuser || !$canviewroster);
next if $$menuitem[4] eq 'mgr'
&& !$canmgr;
next if $$menuitem[4] eq 'nmgr'
@@ -359,19 +364,76 @@ sub secondary_menu {
&& !$canviewwnew;
next if $$menuitem[4] eq 'opa'
&& !$canmodpara;
- next if $$menuitem[4] =~ /showgroups$/
- && !$canviewgrps
- && !%groups;
+ next if $$menuitem[4] eq 'nvcg'
+ && ($canviewgrps || !%groups);
next if $$menuitem[4] eq 'author'
&& !$author;
- if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
+ my $title = $menuitem->[3];
+ if (defined($secondary_submenu{$title})) {
+ my ($link,$target,$numsub);
+ if ($menuitem->[0] ne '') {
+ $link = $menuitem->[0];
+ $target = '_top';
+ } else {
+ $link = '#';
+ }
+
+ my @scndsub;
+ if (ref($secondary_submenu{$title}) eq 'ARRAY') {
+ $numsub = 0;
+ foreach my $item (@{$secondary_submenu{$title}}) {
+ if (ref($item) eq 'ARRAY') {
+ next if ($item->[2] eq 'vgr' && !$canvgr);
+ next if ($item->[2] eq 'opa' && !$canmodpara);
+ next if ($item->[2] eq 'cst' && !$canmodifyuser);
+ next if ($item->[2] eq 'mgr' && !$canmgr);
+ next if ($item->[2] eq 'vcg' && !$canviewgrps);
+ push(@scndsub,$item);
+ $numsub ++;
+ }
+ }
+ if ($numsub) {
+ $title =
+ ''.$title.
+ ''.
+ ' ▼';
+ }
+ }
+ $menu .= ''.
+ ''.$title.'';
+ if ($numsub) {
+ $menu .= '';
+ my $count = 0;
+ foreach my $item (@scndsub) {
+ $count ++;
+ if (ref($item) eq 'ARRAY') {
+ my $borderbot;
+ my ($padtop,$padbot) = (0,0);
+ if ($count == 1) {
+ $padtop = '5px';
+ }
+ if ($count == $numsub) {
+ $padbot = '5px';
+ $borderbot = 'border-bottom:1px solid black;';
+ }
+ $menu .= '- '.
+ $item->[1].'
';
+ }
+ }
+ $menu .= '
';
+ }
+ $menu .= '';
+ } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
my $roles_selector = &roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'} );
- $menu .= $roles_selector ? "$roles_selector"
+ $menu .= $roles_selector ? "$roles_selector"
: '';
} else {
$menu .= &prep_menuitem(\@$menuitem);
@@ -1954,6 +2016,9 @@ BEGIN {
} elsif ($configline=~/^scnd\:/) {
my @entries = (split(/\:/, $configline))[1..5];
push @secondary_menu, \@entries;
+ } elsif ($configline=~/^scndsub\:/) {
+ my ($parent,@entries) = (split(/\:/, $configline))[1..4];
+ push (@{$secondary_submenu{$parent}},\@entries);
} elsif ($configline) {
push(@desklines,$configline);
}