[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm
raeburn
raeburn at source.lon-capa.org
Sun Jan 22 12:10:29 EST 2017
raeburn Sun Jan 22 17:10:29 2017 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonmenu.pm
Log:
- For 2.11
- Backport 1.465
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.67 loncom/interface/lonmenu.pm:1.369.2.68
--- loncom/interface/lonmenu.pm:1.369.2.67 Thu Dec 1 16:53:15 2016
+++ loncom/interface/lonmenu.pm Sun Jan 22 17:10:28 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.67 2016/12/01 16:53:15 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.68 2017/01/22 17:10:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2360,7 +2360,7 @@
my ($cdom,$cnum,$httphost) = @_;
my $crstype = &Apache::loncommon::course_type();
my $now = time;
- my (%courseroles,%seccount,%courseprivs);
+ my (%courseroles,%seccount,%courseprivs,%roledesc);
my $is_cc;
my ($js,$form,$switcher);
my $ccrole;
@@ -2410,7 +2410,7 @@
if ($is_cc) {
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs);
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) {
- &get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$privref);
+ &get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref);
} else {
my %gotnosection;
foreach my $item (keys(%env)) {
@@ -2464,7 +2464,7 @@
}
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
my @submenu;
- $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$privref);
+ $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref);
$form =
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n".
' <input type="hidden" name="destinationurl" value="'.
@@ -2506,7 +2506,10 @@
if ($include) {
my $rolename;
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) {
- $rolename = &mt('Helpdesk [_1]',$1);
+ $rolename = $roledesc{$role};
+ if ($rolename eq '') {
+ $rolename = &mt('Helpdesk [_1]',$1);
+ }
} else {
$rolename = &Apache::lonnet::plaintext($role);
}
@@ -2593,18 +2596,23 @@
}
sub get_customadhoc_roles {
- my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$privref) = @_;
+ my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_;
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
- (ref($courseprivs) eq 'HASH')) {
+ (ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) {
return;
}
- if ($env{'environment.adhocroles.'.$cdom} ne '') {
- my @customroles = split(/,/,$env{'environment.adhocroles.'.$cdom});
- if (@customroles > 1) {
- if ($env{"user.role.dh./$cdom/"}) {
- my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"});
- my $now = time;
- if (!($start && ($now<$start)) & !($end && ($now>$end))) {
+ if ($env{"user.role.dh./$cdom/"}) {
+ my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"});
+ my $now = time;
+ if (!($start && ($now<$start)) && !($end && ($now>$end))) {
+ my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
+ my %available;
+ if (ref($possroles) eq 'ARRAY') {
+ map { $available{$_} = 1; } @{$possroles};
+ }
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+ if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
+ if (keys(%{$domdefaults{'adhocroles'}})) {
my $numsec = 1;
my @sections;
my ($allseclist,$cached) =
@@ -2616,16 +2624,17 @@
}
} else {
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
- $numsec += scalar(keys(%sections_count));
- $allseclist = join(',',sort(keys(%sections_count)));
+ @sections = sort(keys(%sections_count));
+ $numsec += scalar(@sections);
+ $allseclist = join(',', at sections);
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
}
my (%adhoc,$gotprivs);
my $prefix = "cr/$cdom/$cdom".'-domainconfig';
- foreach my $role (@customroles) {
+ foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
next if (($role eq '') || ($role =~ /\W/));
$seccount->{"$prefix/$role"} = $numsec;
- $courseroles->{"$prefix/$role"} = \@sections;
+ $roledesc->{"$prefix/$role"} = $description->{$role};
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
@@ -2646,7 +2655,9 @@
foreach my $key (keys(%roledefs)) {
(undef,my $rolename) = split(/_/,$key);
if ($rolename ne '') {
- $adhoc{$rolename} = $roledefs{$key};
+ my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key});
+ $coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv);
+ $adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv));
}
}
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc);
@@ -2659,6 +2670,9 @@
split(/\_/,$adhoc{$role});
}
}
+ if ($available{$role}) {
+ $courseroles->{"$prefix/$role"} = \@sections;
+ }
}
}
}
@@ -2668,7 +2682,7 @@
}
sub jump_to_role {
- my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$privref) = @_;
+ my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_;
my %lt = &Apache::lonlocal::texthash(
this => 'This role has section(s) associated with it.',
ente => 'Enter a specific section.',
More information about the LON-CAPA-cvs
mailing list