[LON-CAPA-cvs] cvs: loncom /enrollment Autoupdate.pl

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Tue, 05 Jun 2007 23:23:03 -0000


raeburn		Tue Jun  5 19:23:03 2007 EDT

  Modified files:              
    /loncom/enrollment	Autoupdate.pl 
  Log:
  - replace limit to primary domain server with library servers only.
  - filter out courseIDs from just the current server n search for real users
  - iterate over the keys of the roleshash
  - correct name information keys.
  
  
Index: loncom/enrollment/Autoupdate.pl
diff -u loncom/enrollment/Autoupdate.pl:1.9 loncom/enrollment/Autoupdate.pl:1.10
--- loncom/enrollment/Autoupdate.pl:1.9	Mon Jun  4 10:13:08 2007
+++ loncom/enrollment/Autoupdate.pl	Tue Jun  5 19:23:01 2007
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 # Automated Userinfo update script
-# $Id: Autoupdate.pl,v 1.9 2007/06/04 14:13:08 raeburn Exp $
+# $Id: Autoupdate.pl,v 1.10 2007/06/05 23:23:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,7 +36,10 @@
 
     my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');
     my $logfile = $$perlvarref{'lonDaemons'}.'/logs/autoupdate.log';
-    my $hostid = $perlvarref->{'lonHostID'}; 
+    my $hostid = $perlvarref->{'lonHostID'};
+    if (!&Apache::lonnet::is_library($hostid)) {
+        exit;
+    }
     my @info = ('inststatus','lockedname','internalname','lastname',
                 'firstname','id','permanentemail');
     # Initialize language handler
@@ -44,10 +47,6 @@
     # find out which users we need to examine
     my @domains = sort(&Apache::lonnet::current_machine_domains());
     foreach my $dom (@domains) {
-        my $primaryhost_id = &Apache::lonnet::domain($dom,'primary');
-        if ($primaryhost_id ne $hostid) {
-            next;
-        } 
         my %domconfig = &Apache::lonnet::get_dom('configuration',['autoupdate'],
                                                  $dom);
         #only run if configured to
@@ -63,7 +62,7 @@
         open(my $fh,">>$logfile");
         print $fh ("********************\n".localtime(time).' '.&mt('Autoupdate messages start for domain: [_1]',$dom).' --'."\n");
         # get courseIDs for domain
-        my %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','',undef,undef,'.');
+        my %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,[$hostid],'.');
         # get user information
         my (%instusers,%instids);
         next if (&localenroll::allusers_info($dom,\%instusers,\%instids) ne 'ok');
@@ -132,7 +131,7 @@
                                     my %roleshash = 
                                         &Apache::lonnet::get_my_roles($uname,
                                                   $dom,'userroles',\@types,\@roles,\@cdoms);
-                                    foreach my $item (%roleshash) {
+                                    foreach my $item (keys(%roleshash)) {
                                         my ($cnum,$cdom,$role) = split(/:/,$item);
                                         my ($start,$end) = split(/:/,$roleshash{$item});
                                         if (&Apache::lonnet::is_course($cdom,$cnum)) {
@@ -200,8 +199,9 @@
     my ($cdom,$cnum,$udom,$uname,$user) = @_;
     my ($uid,$fullname,$classlistentry);
     my $fullname = 
-        &Apache::lonnet::format_name($user->{'first'},$user->{'middle'},
-                                     $user->{'last'},$user->{'gene'},'lastname');
+        &Apache::lonnet::format_name($user->{'firstname'},$user->{'middlename'},
+                                     $user->{'lastname'},$user->{'generation'},
+                                     'lastname');
     my %classhash = &Apache::lonnet::get('classlist',[$uname.':'.$udom],
                                          $cdom,$cnum);
     my @classinfo = split(/:/,$classhash{$uname.':'.$udom});