[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

droeschl droeschl at source.lon-capa.org
Fri May 18 16:03:22 EDT 2012


droeschl		Fri May 18 20:03:22 2012 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Use dump() routine in privileged instead of reply(“dump”...) to benefit from changes related to BZ 6585.                                
  Code cleanup and comments. 
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1169 loncom/lonnet/perl/lonnet.pm:1.1170
--- loncom/lonnet/perl/lonnet.pm:1.1169	Fri May 18 16:26:05 2012
+++ loncom/lonnet/perl/lonnet.pm	Fri May 18 20:03:22 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1169 2012/05/18 16:26:05 droeschl Exp $
+# $Id: lonnet.pm,v 1.1170 2012/05/18 20:03:22 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4603,32 +4603,18 @@
 
 sub privileged {
     my ($username,$domain)=@_;
-    my $rolesdump=&reply("dump:$domain:$username:roles",
-			&homeserver($username,$domain));
-    if (($rolesdump eq 'con_lost') || ($rolesdump eq '') || 
-        ($rolesdump =~ /^error:/)) {
-        return 0;
-    }
-    my $now=time;
-    if ($rolesdump ne '') {
-        foreach my $entry (split(/&/,$rolesdump)) {
-	    if ($entry!~/^rolesdef_/) {
-		my ($area,$role)=split(/=/,$entry);
-		$area=~s/\_\w\w$//;
-		my ($trole,$tend,$tstart)=split(/_/,$role);
-		if (($trole eq 'dc') || ($trole eq 'su')) {
-		    my $active=1;
-		    if ($tend) {
-			if ($tend<$now) { $active=0; }
-		    }
-		    if ($tstart) {
-			if ($tstart>$now) { $active=0; }
-		    }
-		    if ($active) { return 1; }
-		}
-	    }
+
+    my %rolesdump = &dump("roles", $domain, $username) or return 0;
+    my $now = time;
+
+    for my $role (@rolesdump{grep { ! /^rolesdef_/ } keys %rolesdump}) {
+            my ($trole, $tend, $tstart) = split(/_/, $role);
+            if (($trole eq 'dc') || ($trole eq 'su')) {
+                return 1 unless ($tend && $tend < $now) 
+                    or ($tstart && $tstart > $now);
+            }
 	}
-    }
+
     return 0;
 }
 




More information about the LON-CAPA-cvs mailing list