[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /interface lonmenu.pm
raeburn
raeburn@source.lon-capa.org
Wed, 13 May 2009 03:26:11 -0000
raeburn Wed May 13 03:26:11 2009 EDT
Modified files: (Branch: version_2_8_X)
/loncom/interface lonmenu.pm
Log:
- Backport 1.262, 1.264.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.239.4.3 loncom/interface/lonmenu.pm:1.239.4.4
--- loncom/interface/lonmenu.pm:1.239.4.3 Tue Dec 30 18:39:03 2008
+++ loncom/interface/lonmenu.pm Wed May 13 03:26:11 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.239.4.3 2008/12/30 18:39:03 raeburn Exp $
+# $Id: lonmenu.pm,v 1.239.4.4 2009/05/13 03:26:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1444,7 +1444,7 @@
sub roles_selector {
my ($cdom,$cnum) = @_;
my $now = time;
- my (%courseroles,%seccount,%gotnosection);
+ my (%courseroles,%seccount);
my $is_cc;
my $role_selector;
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
@@ -1459,6 +1459,7 @@
}
}
if ($is_cc) {
+ &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
my %adv_roles =
&Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
foreach my $role (keys(%adv_roles)) {
@@ -1488,6 +1489,7 @@
push(@{$courseroles{'st'}},keys(%sections_count));
}
} else {
+ my %gotnosection;
foreach my $item (keys(%env)) {
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
@@ -1545,6 +1547,61 @@
return $role_selector;
}
+sub get_all_courseroles {
+ my ($cdom,$cnum,$courseroles,$seccount) = @_;
+ unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
+ return;
+ }
+ my ($result,$cached) =
+ &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
+ if (defined($cached)) {
+ if (ref($result) eq 'HASH') {
+ if ((ref($result->{'roles'}) eq 'HASH') &&
+ (ref($result->{'seccount'}) eq 'HASH')) {
+ %{$courseroles} = %{$result->{'roles'}};
+ %{$seccount} = %{$result->{'seccount'}};
+ return;
+ }
+ }
+ }
+ my %gotnosection;
+ my %adv_roles =
+ &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
+ foreach my $role (keys(%adv_roles)) {
+ my ($urole,$usec) = split(/:/,$role);
+ if (!$gotnosection{$urole}) {
+ $seccount->{$urole} ++;
+ $gotnosection{$urole} = 1;
+ }
+ if (ref($courseroles->{$urole}) eq 'ARRAY') {
+ if ($usec ne '') {
+ if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) {
+ push(@{$courseroles->{$urole}},$usec);
+ $seccount->{$urole} ++;
+ }
+ }
+ } else {
+ @{$courseroles->{$urole}} = ();
+ if ($usec ne '') {
+ $seccount->{$urole} ++;
+ push(@{$courseroles->{$urole}},$usec);
+ }
+ }
+ }
+ my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
+ @{$courseroles->{'st'}} = ();
+ if (keys(%sections_count) > 0) {
+ push(@{$courseroles->{'st'}},keys(%sections_count));
+ $seccount->{'st'} = scalar(keys(%sections_count));
+ }
+ my $rolehash = {
+ 'roles' => $courseroles,
+ 'seccount' => $seccount,
+ };
+ &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
+ return;
+}
+
sub jump_to_role {
my ($cdom,$cnum,$seccount,$courseroles) = @_;
my %lt = &Apache::lonlocal::texthash(