--- loncom/automation/Autocreate.pl 2010/03/30 15:24:52 1.13 +++ loncom/automation/Autocreate.pl 2010/09/26 02:29:55 1.16 @@ -2,7 +2,7 @@ # # Automated Course Creation script # -# $Id: Autocreate.pl,v 1.13 2010/03/30 15:24:52 raeburn Exp $ +# $Id: Autocreate.pl,v 1.16 2010/09/26 02:29:55 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -110,8 +110,15 @@ close($fh); exit; } + $env{'user.name'} = $dcname; + $env{'user.domain'} = $dcdom; + $env{'request.role.domain'} = $defdom; + my @permissions = ('mau','ccc','cin','cta','cep','ccr','cst'); + my %permissionflags = (); + &set_permissions(\%permissionflags,\@permissions); my $output = &process_xml($fh,$defdom,$dcname,$dcdom); print $output; + &unset_permissions(\%permissionflags); } } else { my @permissions = ('mau','ccc','cin','cta','cep','ccr','cst'); @@ -142,7 +149,7 @@ } } if ($settings->{'req'}) { - my $output = &Apache::process_official_reqs('auto',$dom); + my $output = &Apache::loncoursequeueadmin::process_official_reqs('auto',$dom); if ($output) { print $fh $output; } @@ -212,21 +219,12 @@ sub process_xml { 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 {