--- loncom/enrollment/Autoenroll.pl 2007/03/01 18:58:42 1.24 +++ loncom/enrollment/Autoenroll.pl 2007/05/14 17:35:01 1.26 @@ -1,7 +1,7 @@ #!/usr/bin/perl # #Automated Enrollment script -# $Id: Autoenroll.pl,v 1.24 2007/03/01 18:58:42 raeburn Exp $ +# $Id: Autoenroll.pl,v 1.26 2007/05/14 17:35:01 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,8 +49,21 @@ # For each domain ...... foreach my $dom (@domains) { - #only run if configured to - if (! &localenroll::run($dom)) { next; } + #only run if configured to + my $run_enroll = 0; + my $settings; + my %domconfig = + &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom); + if (ref($domconfig{'autoenroll'}) eq 'HASH') { + $settings = $domconfig{'autoenroll'}; + if ($settings->{'run'} eq '1') { + $run_enroll = 1; + } + } else { + $run_enroll = &localenroll::run($dom); + } + next if ($run_enroll != 1); + $env{'user.domain'} = $dom; # Initialize language handler &Apache::lonlocal::get_language_handle(); @@ -126,8 +139,8 @@ # Now go through classes and perform required enrollment changes. open (my $fh,">>$logfile"); - print $fh "********************\n".localtime(time)." Enrollment messages start --\n"; - print $fh "Response from fetch_enrollment_query was $outcome\n"; + print $fh "********************\n".localtime(time).' '.&mt('Enrollment messages start').' --'."\n"; + print $fh &mt("Response from [_1] was [_2]",'fetch_enrollment_query',$outcome)."\n"; foreach my $crs (sort keys %enrollvar) { my $logmsg = ''; my $newusermsg = ''; @@ -135,9 +148,9 @@ if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) { if (($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1)) { my ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$enrollvar{$crs}{autoadds},$enrollvar{$crs}{autodrops},$enrollvar{$crs}{startdate},$enrollvar{$crs}{enddate},$enrollvar{$crs}{authtype},$enrollvar{$crs}{autharg},\@{$affiliates{$crs}},\%{$LC_code{$crs}},\$logmsg,\$newusermsg,'automated'); - print $fh "Messages start for $crs\n"; + print $fh &mt('Messages start for [_1]',$crs)."\n"; print $fh "$logmsg\n"; - print $fh "Messages end for $crs\n"; + print $fh &mt('Messages end for [_1]',$crs)."\n"; if ($changecount > 0) { unless ($enrollvar{$crs}{notifylist} eq '') { # Send message about enrollment changes to notifylist. @@ -152,8 +165,8 @@ } $env{'user.home'} = &Apache::lonnet::homeserver($env{'user.name'},$env{'user.domain'}); - my $subject = "Student enrollment changes in $enrollvar{$crs}{coursecode}"; - my $message = "The following $changecount change(s) occurred in $enrollvar{$crs}{description} - $enrollvar{$crs}{coursecode} as a result of the automated classlist update:\n\n".$response; + my $subject = &mt('Student enrollment changes in [_1]',$enrollvar{$crs}{coursecode}); + my $message = &mt('The following [quant,_1,change] occurred in [_2] - [_3] as a result of the automated classlist update:',$changecount,$enrollvar{$crs}{description},$enrollvar{$crs}{coursecode})."\n\n".$response; unless ($newusermsg eq '') { $message .= "\n".$newusermsg; } @@ -173,7 +186,7 @@ my $status = &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message); } if ( ($enrollvar{$crs}{notifylist} eq '') && ($newusermsg ne '') ) { - my $subject = "New user accounts in $enrollvar{$crs}{'coursecode'}"; + my $subject = &mt('New user accounts in [_1]',$enrollvar{$crs}{'coursecode'}); my $status = &Apache::lonmsg::user_normal_msg($env{'user.name'},$env{'user.domain'},$subject,$newusermsg); } delete($env{'user.name'}); @@ -187,19 +200,18 @@ } else { if ( ($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1) ) { if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) { - print $fh "No institutional classlist data could be retrieved for $crs\n"; + print $fh &mt('No institutional classlist data could be retrieved for [_1]',$crs)."\n"; } else { - print $fh "Not within time window for auto-enrollment in $crs\n"; + print $fh ('Not within time window for auto-enrollment in [_1]',$crs)."\n"; } } else { - print $fh "Auto-enrollment not currently enabled for $crs\n"; + print $fh &mt('Auto-enrollment not currently enabled for [_1]',$crs)."\n"; } } } - print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n"; + print $fh "-- ".localtime(time).' '.&mt('Enrollment messages end')."\n*******************\n\n"; close($fh); delete($env{'user.domain'}); -# Check for photos } 1;