[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Fri, 08 May 2009 14:33:16 -0000
raeburn Fri May 8 14:33:16 2009 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- Speed-up for "privileged" user checking in &get_my_roles().
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.998 loncom/lonnet/perl/lonnet.pm:1.999
--- loncom/lonnet/perl/lonnet.pm:1.998 Fri May 8 12:45:28 2009
+++ loncom/lonnet/perl/lonnet.pm Fri May 8 14:33:16 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.998 2009/05/08 12:45:28 raeburn Exp $
+# $Id: lonnet.pm,v 1.999 2009/05/08 14:33:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2747,7 +2747,7 @@
&Apache::lonnet::get_domain_roles($domain,['dc'],$now,$now);
$privileged{$domain} = {};
foreach my $server (keys(%dompersonnel)) {
- if(ref($dompersonnel{$server}) eq 'HASH') {
+ if (ref($dompersonnel{$server}) eq 'HASH') {
foreach my $user (keys(%{$dompersonnel{$server}})) {
my ($trole,$uname,$udom) = split(/:/,$user);
$privileged{$udom}{$uname} = 1;
@@ -2801,6 +2801,7 @@
}
my %returnhash=();
my $now=time;
+ my %privileged;
foreach my $entry (keys(%dumphash)) {
my ($role,$tend,$tstart);
if ($context eq 'userroles') {
@@ -2849,9 +2850,32 @@
}
}
if ($hidepriv) {
- if ((&privileged($username,$domain)) &&
- (!$nothide{$username.':'.$domain})) {
- next;
+ if ($context eq 'userroles') {
+ if ((&privileged($username,$domain)) &&
+ (!$nothide{$username.':'.$domain})) {
+ next;
+ }
+ } else {
+ unless (ref($privileged{$domain}) eq 'HASH') {
+ my %dompersonnel =
+ &Apache::lonnet::get_domain_roles($domain,['dc'],$now,$now);
+ $privileged{$domain} = {};
+ if (keys(%dompersonnel)) {
+ foreach my $server (keys(%dompersonnel)) {
+ if (ref($dompersonnel{$server}) eq 'HASH') {
+ foreach my $user (keys(%{$dompersonnel{$server}})) {
+ my ($trole,$uname,$udom) = split(/:/,$user);
+ $privileged{$udom}{$uname} = $trole;
+ }
+ }
+ }
+ }
+ }
+ if (exists($privileged{$domain}{$username})) {
+ if (!$nothide{$username.':'.$domain}) {
+ next;
+ }
+ }
}
}
if ($withsec) {