--- loncom/interface/domainprefs.pm 2014/04/06 00:25:26 1.160.6.38 +++ loncom/interface/domainprefs.pm 2014/03/29 20:35:21 1.231 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.38 2014/04/06 00:25:26 raeburn Exp $ +# $Id: domainprefs.pm,v 1.231 2014/03/29 20:35:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -164,7 +164,6 @@ 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(); @@ -212,15 +211,15 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','coursedefaults', - 'usersessions','loadbalancing','requestauthor', - 'selfenrollment'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor','selfenrollment'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','selfcreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','coursedefaults','selfenrollment', - 'usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','selfenrollment','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -400,7 +399,15 @@ sub handler { print => \&print_serverstatuses, modify => \&modify_serverstatuses, }, - 'coursedefaults' => + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], + print => \&print_helpsettings, + modify => \&modify_helpsettings, + }, + 'coursedefaults' => {text => 'Course/Community defaults', help => 'Domain_Configuration_Course_Defaults', header => [{col1 => 'Defaults which can be overridden in each course by a CC', @@ -410,7 +417,7 @@ sub handler { print => \&print_coursedefaults, modify => \&modify_coursedefaults, }, - 'selfenrollment' => + 'selfenrollment' => {text => 'Self-enrollment in Course/Community', help => 'Domain_Configuration_Selfenrollment', header => [{col1 => 'Configuration Rights', @@ -422,6 +429,14 @@ sub handler { print => \&print_selfenrollment, modify => \&modify_selfenrollment, }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + print => \&print_privacy, + modify => \&modify_privacy, + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -606,6 +621,8 @@ sub process_changes { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'requestauthor') { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); } elsif ($action eq 'selfenrollment') { @@ -657,8 +674,8 @@ sub print_config_box { '; $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || - ($action eq 'usermodification') || ($action eq 'selfenrollment') || - ($action eq 'usersessions')) { + ($action eq 'usermodification') || ($action eq 'coursedefaults') || + ($action eq 'selfenrollment') || ($action eq 'usersessions')) { $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal); @@ -2822,8 +2839,8 @@ sub print_selfenrollment { my $itemcount = 1; my @types = ('official','unofficial','community','textbook'); if (($position eq 'top') || ($position eq 'middle')) { - my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); - my %descs = &Apache::lonuserutils::selfenroll_default_descs(); + my ($rowsref,$titlesref) = &get_selfenroll_titles(); + my %descs = &selfenroll_default_descs(); my @rows; my $key; if ($position eq 'top') { @@ -2956,7 +2973,7 @@ sub print_selfenrollment { $datatable .= ''; } } elsif ($position eq 'bottom') { - my ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types(); + my ($itemsref,$namesref,$fieldsref) = &selfenroll_validation_types(); my %currvalidation; if (ref($settings) eq 'HASH') { if (ref($settings->{'validation'}) eq 'HASH') { @@ -3001,6 +3018,58 @@ 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); @@ -3983,7 +4052,7 @@ sub print_selfcreation { ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, \%choices,$itemcount,$onclick); $$rowtotal += $itemcount; - + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); if (ref($usertypes) eq 'HASH') { @@ -5086,7 +5155,7 @@ sub modifiable_userdata_row { if ($statustype) { if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') { $hashref = $settings->{$context}->{$role}->{$statustype}; - if (ref($hashref) eq 'HASH') { + if (ref($hashref) eq 'HASH') { foreach my $field (@fields) { if ($hashref->{$field}) { $checks{$field} = $hashref->{$field}; @@ -5107,7 +5176,7 @@ sub modifiable_userdata_row { } } } - + for (my $i=0; $i<@fields; $i++) { my $rem = $i%($numinrow); if ($rem == 0) { @@ -5123,7 +5192,7 @@ sub modifiable_userdata_row { } else { if ($role eq 'st') { if (ref($settings) ne 'HASH') { - $check = ' checked="checked" '; + $check = ' checked="checked" '; } } } @@ -9341,8 +9410,8 @@ sub modify_selfenrollment { my ($resulttext,$errors,%changes,%selfenrollhash,%ordered); my @types = ('official','unofficial','community','textbook'); my %titles = &tool_titles(); - my %descs = &Apache::lonuserutils::selfenroll_default_descs(); - ($ordered{'admin'},my $titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); + my %descs = &selfenroll_default_descs(); + ($ordered{'admin'},my $titlesref) = &get_selfenroll_titles(); $ordered{'default'} = ['types','registered','approval','limit']; my (%roles,%shown,%toplevel); @@ -9358,7 +9427,7 @@ sub modify_selfenrollment { default => 'Default settings', validation => 'Validation of self-enrollment requests', ); - my ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types(); + my ($itemsref,$namesref,$fieldsref) = &selfenroll_validation_types(); if (ref($ordered{'admin'}) eq 'ARRAY') { foreach my $item (@{$ordered{'admin'}}) { @@ -9508,34 +9577,6 @@ 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 .= '
  • '.$titles{$type}.'
  • '; } } - if ((exists($changes{'admin'})) || (exists($changes{'default'}))) { - my $cachetime = 24*60*60; - &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } - } } $resulttext .= ''; } else {