--- loncom/interface/domainprefs.pm 2014/03/29 20:35:21 1.231 +++ loncom/interface/domainprefs.pm 2014/03/31 01:09:11 1.232 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.231 2014/03/29 20:35:21 raeburn Exp $ +# $Id: domainprefs.pm,v 1.232 2014/03/31 01:09:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -164,6 +164,7 @@ use Apache::lonhtmlcommon(); use Apache::lonlocal; use Apache::lonmsg(); use Apache::lonconfigsettings; +use Apache::lonuserutils(); use LONCAPA qw(:DEFAULT :match); use LONCAPA::Enrollment; use LONCAPA::lonauthcgi(); @@ -2839,8 +2840,8 @@ sub print_selfenrollment { my $itemcount = 1; my @types = ('official','unofficial','community','textbook'); if (($position eq 'top') || ($position eq 'middle')) { - my ($rowsref,$titlesref) = &get_selfenroll_titles(); - my %descs = &selfenroll_default_descs(); + my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); + my %descs = &Apache::lonuserutils::selfenroll_default_descs(); my @rows; my $key; if ($position eq 'top') { @@ -3018,58 +3019,6 @@ sub print_selfenrollment { return $datatable; } -sub get_selfenroll_titles { - my @row = ('types','registered','enroll_dates','access_dates','section', - 'approval','limit'); - my %lt = &Apache::lonlocal::texthash ( - types => 'Users allowed to self-enroll', - registered => 'Registration status (official courses)' , - enroll_dates => 'Dates self-enrollment available', - access_dates => 'Access dates for self-enrolling users', - section => 'Self-enrolling users section', - approval => 'Processing of requests', - limit => 'Enrollment limit', - ); - return (\@row,\%lt); -} - -sub selfenroll_default_descs { - my %desc = ( - types => { - dom => &mt('Course domain'), - all => &mt('Any domain'), - '' => &mt('None'), - }, - limit => { - none => &mt('No limit'), - allstudents => &mt('Limit by total students'), - selfenrolled => &mt('Limit by total self-enrolled'), - }, - approval => { - '0' => &mt('Processed automatically'), - '1' => &mt('Queued for approval'), - '2' => &mt('Queued, pending validation'), - }, - registered => { - 0 => 'No registration required', - 1 => 'Registered students only', - }, - ); - return %desc; -} - -sub selfenroll_validation_types { - my @items = ('url','fields','button','markup'); - my %names = &Apache::lonlocal::texthash ( - url => 'Web address of validation server/script', - fields => 'Form fields to send to validator', - button => 'Text for validation button', - markup => 'Validation description (HTML)', - ); - my @fields = ('username','domain','uniquecode','course','token'); - return (\@items,\%names,\@fields); -} - sub print_usersessions { my ($position,$dom,$settings,$rowtotal) = @_; my ($css_class,$datatable,%checked,%choices); @@ -9410,8 +9359,8 @@ sub modify_selfenrollment { my ($resulttext,$errors,%changes,%selfenrollhash,%ordered); my @types = ('official','unofficial','community','textbook'); my %titles = &tool_titles(); - my %descs = &selfenroll_default_descs(); - ($ordered{'admin'},my $titlesref) = &get_selfenroll_titles(); + my %descs = &Apache::lonuserutils::selfenroll_default_descs(); + ($ordered{'admin'},my $titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); $ordered{'default'} = ['types','registered','approval','limit']; my (%roles,%shown,%toplevel); @@ -9577,6 +9526,34 @@ sub modify_selfenrollment { $roles{'1'} = &mt('Course personnel'); } if (ref($changes{$key}{$type}) eq 'ARRAY') { + if (ref($selfenrollhash{$key}{$type}) eq 'HASH') { + if ($key eq 'admin') { + my @mgrdc = (); + if (ref($ordered{$key}) eq 'ARRAY') { + foreach my $item (@{$ordered{'admin'}}) { + if (ref($selfenrollhash{$key}{$type}) eq 'HASH') { + if ($selfenrollhash{$key}{$type}{$item} eq '0') { + push(@mgrdc,$item); + } + } + } + if (@mgrdc) { + $domdefaults{$type.'selfenrolladmdc'} = join(',',@mgrdc); + } else { + delete($domdefaults{$type.'selfenrolladmdc'}); + } + } + } else { + if (ref($ordered{$key}) eq 'ARRAY') { + foreach my $item (@{$ordered{$key}}) { + if (grep(/^\Q$item\E$/,@{$changes{$key}{$type}})) { + $domdefaults{$type.'selfenroll'.$item} = + $selfenrollhash{$key}{$type}{$item}; + } + } + } + } + } $resulttext .= '