--- loncom/enrollment/Autoupdate.pl 2009/03/09 05:25:49 1.13 +++ loncom/enrollment/Autoupdate.pl 2010/03/25 04:21:32 1.17 @@ -1,7 +1,7 @@ #!/usr/bin/perl # # Automated Userinfo update script -# $Id: Autoupdate.pl,v 1.13 2009/03/09 05:25:49 raeburn Exp $ +# $Id: Autoupdate.pl,v 1.17 2010/03/25 04:21:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ exit; } my @info = ('inststatus','lockedname','internalname','lastname', - 'firstname','id','permanentemail'); + 'firstname','middlename','generation','id','permanentemail'); # Initialize language handler &Apache::lonlocal::get_language_handle(); # find out which users we need to examine @@ -61,7 +61,7 @@ } next if (!$run_update); open(my $fh,">>$logfile"); - print $fh ("********************\n".localtime(time).' '.&mt('Autoupdate messages start for domain: [_1]',$dom).' --'."\n"); + print $fh ("********************\n".&Apache::lonlocal::locallocaltime(time).' '.&mt('Autoupdate messages start for domain: [_1]',$dom).' --'."\n"); # get courseIDs for domain my %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,[$hostid],'.'); # get user information @@ -112,7 +112,7 @@ if ($settings->{'classlists'} == 1) { if ($field eq 'id') { $changes{'id'} = 1; - } elsif ($field eq 'lastname' || $field eq 'firstname' || $field eq 'middlename' || $field eq 'gen') { + } elsif ($field eq 'lastname' || $field eq 'firstname' || $field eq 'middlename' || $field eq 'generation') { $changes{'fullname'} = 1; } } @@ -121,10 +121,14 @@ # Make the change if ($changed) { my %userupdate; + foreach my $item ('lastname','firstname','middlename','generation','id', + 'permanentemail') { + $userupdate{$item} = $userhash{$item}; + } foreach my $field (@fields) { $userupdate{$field} = $instusers{$uname}{$field}; } - my $modresult = &Apache::lonnet::modifyuser($dom,$uname,$userupdate{'id'},undef,undef,$userupdate{'firstname'},$userupdate{'middlename'},$userupdate{'lastname'},$userupdate{'generation'},1,$hostid,$userupdate{'permanentemail'}); + my $modresult = &Apache::lonnet::modifyuser($dom,$uname,$userupdate{'id'},undef,undef,$userupdate{'firstname'},$userupdate{'middlename'},$userupdate{'lastname'},$userupdate{'generation'},1,$hostid,$userupdate{'permanentemail'},undef,\@fields); if ($modresult eq 'ok') { print $fh "User change: $uname:$dom; New values: 1.Name: $userupdate{'firstname'} $userupdate{'middlename'} $userupdate{'lastname'} $userupdate{'generation'}; 2. StuID: $userupdate{'id'}; 3. Email: $userupdate{'permanentemail'}.\n"; if ($settings->{'classlists'} == 1) {