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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Tue, 29 May 2007 20:43:17 -0000


raeburn		Tue May 29 16:43:17 2007 EDT

  Modified files:              
    /loncom/enrollment	Autoupdate.pl 
  Log:
  - Initialize language handler
  - Logging to an autoupdate.log file
  
  
Index: loncom/enrollment/Autoupdate.pl
diff -u loncom/enrollment/Autoupdate.pl:1.5 loncom/enrollment/Autoupdate.pl:1.6
--- loncom/enrollment/Autoupdate.pl:1.5	Fri May 11 13:25:28 2007
+++ loncom/enrollment/Autoupdate.pl	Tue May 29 16:43:17 2007
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 # Automated Userinfo update script
-# $Id: Autoupdate.pl,v 1.5 2007/05/11 17:25:28 raeburn Exp $
+# $Id: Autoupdate.pl,v 1.6 2007/05/29 20:43:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,8 +35,12 @@
     use LONCAPA;
 
     my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');
+    my $logfile = $$perlvarref{'lonDaemons'}.'/logs/autoupdate.log';
     my $hostid = $perlvarref->{'lonHostID'}; 
-    my @info = ('inststatus','lockedname','lastname','firstname','id');
+    my @info = ('inststatus','lockedname','internalname','lastname',
+                'firstname','id');
+    # Initialize language handler
+    &Apache::lonlocal::get_language_handle();
     # find out which users we need to examine
     my @domains = sort(&Apache::lonnet::current_machine_domains());
     foreach my $dom (@domains) {
@@ -56,6 +60,8 @@
             }
         }
         next if (!$run_update);
+        open (my $fh,">>$logfile");
+        print $fh "********************\n".localtime(time).' '.&mt('Autoupdate messages start for domain: [_1]',$dom).' --'."\n";
         # get user information
         my (%instusers,%instids);
         next if (&localenroll::allusers_info($dom,\%instusers,\%instids) ne 'ok');
@@ -145,7 +151,7 @@
                         } else {
                             if (!exists($users{$instids{$userhash{'id'}}})) {
                                 $unamechg{$uname} = $instids{$userhash{'id'}};
-                                print &mt('Username change to [_1] detected for [_2] in domain [_3].',$unamechg{$uname},$uname,$dom)."\n";
+                                print $fh &mt('Username change to [_1] detected for [_2] in domain [_3].',$unamechg{$uname},$uname,$dom)."\n";
                             }
                         }
                     }
@@ -155,9 +161,11 @@
         if (keys(%possnames) > 0) {
             foreach my $uname (keys(%possnames)) {
                 my $altnames = join(' or ',@{$possnames{$uname}});
-                print &mt('Possible username change to [_1] detected for [_2] in domain [_3].',$altnames,$uname,$dom)."\n";
+                print $fh &mt('Possible username change to [_1] detected for [_2] in domain [_3].',$altnames,$uname,$dom)."\n";
             }
         }
+        print $fh "-- ".localtime(time).' '.&mt('Autoupdate messages end')."\n*******************\n\n";
+        close($fh);
     }
 
 sub descend_tree {