[LON-CAPA-cvs] cvs: loncom /automation Autocreate.pl

raeburn raeburn@source.lon-capa.org
Sun, 26 Sep 2010 02:29:55 -0000


raeburn		Sun Sep 26 02:29:55 2010 EDT

  Modified files:              
    /loncom/automation	Autocreate.pl 
  Log:
  - Use lonnet::get_my_roles() in place of lonnet::dump() when determining if 
    the user under whose identity Autocreate.pl is being run has an active DC 
    role in the domain.
  
  
Index: loncom/automation/Autocreate.pl
diff -u loncom/automation/Autocreate.pl:1.15 loncom/automation/Autocreate.pl:1.16
--- loncom/automation/Autocreate.pl:1.15	Sat Aug 28 19:00:42 2010
+++ loncom/automation/Autocreate.pl	Sun Sep 26 02:29:55 2010
@@ -2,7 +2,7 @@
 #
 # Automated Course Creation script
 #
-# $Id: Autocreate.pl,v 1.15 2010/08/28 19:00:42 raeburn Exp $
+# $Id: Autocreate.pl,v 1.16 2010/09/26 02:29:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -219,21 +219,12 @@
 
 sub check_activedc {
     my ($dcdom,$dcname,$defdom) = @_;
-    my %dumphash=
-            &Apache::lonnet::dump('roles',$dcdom,$dcname);
-    my $now=time;
-    my $activedc = 0;
-    foreach my $item (keys %dumphash) {
-        my ($domain,$role) = ($item =~ m-^/([^/]+)/[^_]*_(\w+)$-);
-        if ($role eq 'dc' && $domain eq $defdom) {
-            my ($trole,$tend,$tstart)=split(/_/,$dumphash{$item});
-            if (($tend) && ($tend<$now)) { next; }
-            if (($tstart) && ($now<$tstart)) { next; }
-            $activedc = 1;
-            last;
-        }
+    my %roleshash = 
+        &Apache::lonnet::get_my_roles($dcname,$dcdom,'userroles',undef,['dc'],[$defdom]);
+    if (keys(%roleshash) > 0) {
+        return 1;
     }
-    return $activedc;
+    return 0;
 }
 
 sub set_permissions {