[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sat May 11 23:36:47 EDT 2013
raeburn Sun May 12 03:36:47 2013 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface loncommon.pm
Log:
- For 2.11
- Backport 1.1121.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.35 loncom/interface/loncommon.pm:1.1075.2.36
--- loncom/interface/loncommon.pm:1.1075.2.35 Fri May 10 23:18:42 2013
+++ loncom/interface/loncommon.pm Sun May 12 03:36:46 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.35 2013/05/10 23:18:42 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.36 2013/05/12 03:36:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2161,7 +2161,7 @@
=pod
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoma,$excdoms)
Returns a string containing a <select name='$name' size='1'> form to
allow a user to select the domain to preform an operation in.
@@ -2174,25 +2174,31 @@
The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted.
-The optional $incdoms is a reference to an array of domains which will be the only available options.
+The optional $incdoms is a reference to an array of domains which will be the only available options.
+
+The optional $excdoms is a reference to an array of domains which will be excluded from the available options.
=cut
#-------------------------------------------
sub select_dom_form {
- my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) = @_;
+ my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) = @_;
if ($onchange) {
$onchange = ' onchange="'.$onchange.'"';
}
- my @domains;
+ my (@domains,%exclude);
if (ref($incdoms) eq 'ARRAY') {
@domains = sort {lc($a) cmp lc($b)} (@{$incdoms});
} else {
@domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
}
if ($includeempty) { @domains=('', at domains); }
+ if (ref($excdoms) eq 'ARRAY') {
+ map { $exclude{$_} = 1; } @{$excdoms};
+ }
my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
foreach my $dom (@domains) {
+ next if ($exclude{$dom});
$selectdomain.="<option value=\"$dom\" ".
($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;
if ($showdomdesc) {
@@ -8396,7 +8402,7 @@
active => 'Active',
future => 'Future',
);
- my %nothide;
+ my (%nothide, at possdoms);
if ($hidepriv) {
my %coursehash=&Apache::lonnet::coursedescription($cdom.'_'.$cnum);
foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
@@ -8406,6 +8412,10 @@
$nothide{$user} = 1;
}
}
+ my @possdoms = ($cdom);
+ if ($coursehash{'checkforpriv'}) {
+ push(@possdoms,split(/,/,$coursehash{'checkforpriv'}));
+ }
}
foreach my $person (sort(keys(%coursepersonnel))) {
my $match = 0;
@@ -8441,7 +8451,7 @@
}
if ($uname ne '' && $udom ne '') {
if ($hidepriv) {
- if ((&Apache::lonnet::privileged($uname,$udom)) &&
+ if ((&Apache::lonnet::privileged($uname,$udom,\@possdoms)) &&
(!$nothide{$uname.':'.$udom})) {
next;
}
@@ -13630,6 +13640,7 @@
'pch.users.denied',
'plc.users.denied',
'hidefromcat',
+ 'checkforpriv',
'categories'],
$$crsudom,$$crsunum);
}
@@ -13686,6 +13697,11 @@
# do not hide course coordinator from staff listing,
# even if privileged
$cenv{'nothideprivileged'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
+# add course coordinator's domain to domains to check for privileged users
+# if different to course domain
+ if ($$crsudom ne $args->{'ccdomain'}) {
+ $cenv{'checkforpriv'} = $args->{'ccdomain'};
+ }
# add crosslistings
if ($args->{'crsxlist'}) {
$cenv{'internal.crosslistings'}='';
More information about the LON-CAPA-cvs
mailing list