--- loncom/interface/domainprefs.pm 2008/07/19 02:28:44 1.64
+++ loncom/interface/domainprefs.pm 2009/08/08 00:36:00 1.101
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.64 2008/07/19 02:28:44 raeburn Exp $
+# $Id: domainprefs.pm,v 1.101 2009/08/08 00:36:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,6 +28,131 @@
###############################################################
##############################################################
+=pod
+
+=head1 NAME
+
+Apache::domainprefs.pm
+
+=head1 SYNOPSIS
+
+Handles configuration of a LON-CAPA domain.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+
+=head1 OVERVIEW
+
+Each institution using LON-CAPA will typically have a single domain designated
+for use by individuals affliated with the institution. Accordingly, each domain
+may define a default set of logos and a color scheme which can be used to "brand"
+the LON-CAPA instance. In addition, an institution will typically have a language
+and timezone which are used for the majority of courses.
+
+LON-CAPA provides a mechanism to display and modify these defaults, as well as a
+host of other domain-wide settings which determine the types of functionality
+available to users and courses in the domain.
+
+There is also a mechanism to configure cataloging of courses in the domain, and
+controls on the operation of automated processes which govern such things as
+roster updates, user directory updates and processing of course requests.
+
+The domain coordination manual which is built dynamically on install/update of
+LON-CAPA from the relevant help items provides more information about domain
+configuration.
+
+Most of the domain settings are stored in the configuration.db GDBM file which is
+housed on the primary library server for the domain in /home/httpd/lonUsers/$dom,
+where $dom is the domain. The configuration.db stores settings in a number of
+frozen hashes of hashes. In a few cases, domain information must be uploaded to
+the domain as files (e.g., image files for logos etc., or plain text files for
+bubblesheet formats). In this case the domainprefs.pm must be running in a user
+session hosted on the primary library server in the domain, as these files are
+stored in author space belonging to a special $dom-domainconfig user.
+
+domainprefs.pm in combination with lonconfigsettings.pm will retrieve and display
+the current settings, and provides an interface to make modifications.
+
+=head1 SUBROUTINES
+
+=over
+
+=item print_quotas()
+
+Inputs: 4
+
+$dom,$settings,$rowtotal,$action.
+
+$dom is the domain, $settings is a reference to a hash of current settings for
+the current context, $rowtotal is a reference to the scalar used to record the
+number of rows displayed on the page, and $action is the context (either quotas
+or requestcourses).
+
+The print_quotas routine was orginally created to display/store information
+about default quota sizes for portfolio spaces for the different types of
+institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
+but is now also used to manage availability of user tools:
+i.e., blogs, aboutme page, and portfolios, and the course request tool,
+used by course owners to request creation of a course.
+
+Outputs: 1
+
+$datatable - HTML containing form elements which allow settings to be changed.
+
+In the case of course requests, radio buttons are displayed for each institutional
+affiliate type (and also default, and _LC_adv) for each of the course types
+(official, unofficial and community). In each case the radio buttons allow the
+selection of one of four values:
+
+0, approve, validate, autolimit=N (where N is blank, or a positive integer).
+which have the following effects:
+
+0
+
+=over
+
+- course requests are not allowed for this course types/affiliation
+
+=back
+
+approve
+
+=over
+
+- course requests must be approved by a Doman Coordinator in the
+course's domain
+
+=back
+
+validate
+
+=over
+
+- an institutional validation (e.g., check requestor is instructor
+of record) needs to be passed before the course will be created. The required
+validation is in localenroll.pm on the primary library server for the course
+domain.
+
+=back
+
+autolimit
+
+=over
+
+- course requests will be processed autoatically up to a limit of
+N requests for the course type for the particular requestor.
+If N is undefined, there is no limit to the number of course requests
+which a course owner may submit and have processed automatically.
+
+=back
+
+=item modify_quotas()
+
+=back
+
+=cut
+
package Apache::domainprefs;
use strict;
@@ -37,11 +162,14 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonmsg();
-use LONCAPA;
+use Apache::lonconfigsettings;
+use LONCAPA qw(:DEFAULT :match);
use LONCAPA::Enrollment;
+use LONCAPA::lonauthcgi();
use File::Copy;
use Locale::Language;
use DateTime::TimeZone;
+use DateTime::Locale;
sub handler {
my $r=shift;
@@ -51,6 +179,7 @@ sub handler {
return OK;
}
+ my $context = 'domain';
my $dom = $env{'request.role.domain'};
my $domdesc = &Apache::lonnet::domain($dom,'description');
if (&Apache::lonnet::allowed('mau',$dom)) {
@@ -72,15 +201,16 @@ sub handler {
&Apache::lonnet::get_dom('configuration',['login','rolecolors',
'quotas','autoenroll','autoupdate','directorysrch',
'usercreation','usermodification','contacts','defaults',
- 'scantron','coursecategories'],$dom);
+ 'scantron','coursecategories','serverstatuses',
+ 'requestcourses'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'coursecategories');
+ 'requestcourses','coursecategories','serverstatuses');
my %prefs = (
'rolecolors' =>
{ text => 'Default color schemes',
- help => 'Default_Color_Schemes',
+ help => 'Domain_Configuration_Color_Schemes',
header => [{col1 => 'Student Settings',
col2 => '',},
{col1 => 'Coordinator Settings',
@@ -92,31 +222,32 @@ sub handler {
},
'login' =>
{ text => 'Log-in page options',
- help => 'Domain_Log-in_Page',
+ help => 'Domain_Configuration_Login_Page',
header => [{col1 => 'Item',
col2 => '',}],
},
'defaults' =>
{ text => 'Default authentication/language/timezone',
- help => '',
+ help => 'Domain_Configuration_LangTZAuth',
header => [{col1 => 'Setting',
col2 => 'Value'}],
},
'quotas' =>
- { text => 'Default quotas for user portfolios',
- help => 'Default_User_Quota',
- header => [{col1 => 'User type',
- col2 => 'Default quota'}],
+ { text => 'User blogs, personal information pages and portfolios',
+ help => 'Domain_Configuration_Quotas',
+ header => [{col1 => 'User affiliation',
+ col2 => 'Available tools',
+ col3 => 'Portfolio quota',}],
},
'autoenroll' =>
{ text => 'Auto-enrollment settings',
- help => 'Domain_Auto_Enrollment',
+ help => 'Domain_Configuration_Auto_Enrollment',
header => [{col1 => 'Configuration setting',
col2 => 'Value(s)'}],
},
'autoupdate' =>
{ text => 'Auto-update settings',
- help => 'Domain_Auto_Update',
+ help => 'Domain_Configuration_Auto_Updates',
header => [{col1 => 'Setting',
col2 => 'Value',},
{col1 => 'User population',
@@ -124,20 +255,20 @@ sub handler {
},
'directorysrch' =>
{ text => 'Institutional directory searches',
- help => 'Domain_Directory_Search',
+ help => 'Domain_Configuration_InstDirectory_Search',
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
'contacts' =>
{ text => 'Contact Information',
- help => 'Domain_Contact_Information',
+ help => 'Domain_Configuration_Contact_Info',
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
'usercreation' =>
{ text => 'User creation',
- help => 'Domain_User_Creation',
+ help => 'Domain_Configuration_User_Creation',
header => [{col1 => 'Format rule type',
col2 => 'Format rules in force'},
{col1 => 'User account creation',
@@ -145,9 +276,9 @@ sub handler {
{col1 => 'Context',
col2 => 'Assignable authentication types'}],
},
- 'usermodification' =>
+ 'usermodification' =>
{ text => 'User modification',
- help => 'Domain_User_Modification',
+ help => 'Domain_Configuration_User_Modification',
header => [{col1 => 'Target user has role',
col2 => 'User information updateable in author context'},
{col1 => 'Target user has role',
@@ -155,22 +286,36 @@ sub handler {
{col1 => "Status of user",
col2 => 'Information settable when self-creating account (if directory data blank)'}],
},
- 'scantron' =>
- { text => 'Scantron format file',
- help => 'Domain_Scantron_Formats',
+ 'scantron' =>
+ { text => 'Bubblesheet format file',
+ help => 'Domain_Configuration_Scantron_Format',
header => [ {col1 => 'Item',
col2 => '',
}],
},
- 'coursecategories' =>
+ 'requestcourses' =>
+ {text => 'Request creation of courses',
+ help => 'Domain_Configuration_Request_Courses',
+ header => [{col1 => 'User affiliation',
+ col2 => 'Availability/Processing of requests',}],
+ },
+ 'coursecategories' =>
{ text => 'Cataloging of courses',
- help => 'Domain_Course_Catalog',
- header => [{col1 => 'Category settings',
+ help => 'Domain_Configuration_Cataloging_Courses',
+ header => [{col1 => 'Category settings',
col2 => '',},
{col1 => 'Categories',
col2 => '',
}],
- }
+ },
+ 'serverstatuses' =>
+ {text => 'Access to server status pages',
+ help => 'Domain_Configuration_Server_Status',
+ header => [{col1 => 'Status Page',
+ col2 => 'Other named users',
+ col3 => 'Specific IPs',
+ }],
+ },
);
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
@@ -179,98 +324,10 @@ sub handler {
text=>"Pick functionality"});
my $confname = $dom.'-domainconfig';
if ($phase eq 'process') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:changePage(document.$phase,'display')",
- text=>"Domain Configuration"},
- {href=>"javascript:changePage(document.$phase,'$phase')",
- text=>"Updated"});
- &print_header($r,$phase);
- foreach my $item (@prefs_order) {
- if (grep(/^\Q$item\E$/,@actions)) {
- $r->print('
';
} else {
my $newitem = $confhash->{$role}{$item};
@@ -3261,71 +3673,228 @@ sub check_switchserver {
return $switchserver;
}
-sub javascript_set_colnums {
- return < 1100) {
- document.pickactions.numcols[1].checked = true;
+sub modify_quotas {
+ my ($dom,$action,%domconfig) = @_;
+ my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
+ %limithash,$toolregexp,%conditions,$resulttext,%changes);
+ if ($action eq 'quotas') {
+ $context = 'tools';
+ } else {
+ $context = $action;
+ }
+ if ($context eq 'requestcourses') {
+ @usertools = ('official','unofficial','community');
+ @options =('norequest','approve','autolimit','validate');
+ %validations = &Apache::lonnet::auto_courserequest_checks($dom);
+ %titles = &courserequest_titles();
+ $toolregexp = join('|',@usertools);
+ %conditions = &courserequest_conditions();
} else {
- document.pickactions.numcols[0].checked = true;
+ @usertools = ('aboutme','blog','portfolio');
+ %titles = &tool_titles();
}
-}
-END
-}
-
-sub modify_quotas {
- my ($dom,%domconfig) = @_;
- my ($resulttext,%changes);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my %formhash;
foreach my $key (keys(%env)) {
- if ($key =~ /^form\.quota_(.+)$/) {
- $formhash{$1} = $env{$key};
+ if ($context eq 'requestcourses') {
+ if ($key =~ /^form\.crsreq_($toolregexp)_(.+)$/) {
+ my $item = $1;
+ my $type = $2;
+ if ($type =~ /^limit_(.+)/) {
+ $limithash{$item}{$1} = $env{$key};
+ } else {
+ $confhash{$item}{$type} = $env{$key};
+ }
+ }
+ } else {
+ if ($key =~ /^form\.quota_(.+)$/) {
+ $confhash{'defaultquota'}{$1} = $env{$key};
+ }
+ if ($key =~ /^form\.\Q$context\E_(.+)$/) {
+ @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
+ }
}
}
- $formhash{'default'} = $env{'form.defaultquota'};
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'quotas'}})) {
- if (exists($formhash{$key})) {
- if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
- $changes{$key} = 1;
+ unless ($context eq 'requestcourses') {
+ $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
+ }
+ foreach my $item (@usertools) {
+ foreach my $type (@{$types},'default','_LC_adv') {
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} eq 'autolimit') {
+ $confhash{$item}{$type} .= '=';
+ unless ($limithash{$item}{$type} =~ /\D/) {
+ $confhash{$item}{$type} .= $limithash{$item}{$type};
+ }
+ }
+ } else {
+ if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
+ $confhash{$item}{$type} = 1;
+ } else {
+ $confhash{$item}{$type} = 0;
+ }
+ }
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$item}) eq 'HASH') {
+ if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} ne 'norequest') {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ }
}
} else {
- $formhash{$key} = $domconfig{'quotas'}{$key};
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} eq 'norequest') {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ }
}
}
}
- foreach my $key (keys(%formhash)) {
- if ($formhash{$key} ne '') {
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- if (!exists($domconfig{'quotas'}{$key})) {
- $changes{$key} = 1;
+ unless ($context eq 'requestcourses') {
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
+ if (exists($confhash{'defaultquota'}{$key})) {
+ if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{'defaultquota'}{$key}) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{'defaultquota'}{$key};
+ }
}
} else {
- $changes{$key} = 1;
+ foreach my $key (keys(%{$domconfig{'quotas'}})) {
+ if (exists($confhash{'defaultquota'}{$key})) {
+ if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{$key}) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{$key};
+ }
+ }
+ }
+ }
+ if (ref($confhash{'defaultquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$confhash{'defaultquota'}})) {
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
+ if (!exists($domconfig{'quotas'}{'defaultquota'}{$key})) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ if (!exists($domconfig{'quotas'}{$key})) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ }
+ } else {
+ $changes{'defaultquota'}{$key} = 1;
+ }
}
}
}
+
+ foreach my $key (keys(%confhash)) {
+ $domdefaults{$key} = $confhash{$key};
+ }
+
my %quotahash = (
- quotas => {%formhash},
+ $action => { %confhash }
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+
$resulttext = &mt('Changes made:').'
';
- foreach my $type (@{$types},'default') {
- if (defined($changes{$type})) {
- my $typetitle = $usertypes->{$type};
- if ($type eq 'default') {
- $typetitle = $othertitle;
+ unless ($context eq 'requestcourses') {
+ if (ref($changes{'defaultquota'}) eq 'HASH') {
+ $resulttext .= '
'.&mt('Portfolio default quotas').'
';
+ foreach my $type (@{$types},'default') {
+ if (defined($changes{'defaultquota'}{$type})) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ }
+ $resulttext .= '
'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'
';
+ }
+ }
+ $resulttext .= '
';
+ }
+ }
+ my %newenv;
+ foreach my $item (@usertools) {
+ if (ref($changes{$item}) eq 'HASH') {
+ my $newacc =
+ &Apache::lonnet::usertools_access($env{'user.name'},
+ $env{'user.domain'},
+ $item,'reload',$context);
+ if ($context eq 'requestcourses') {
+ if ($env{'environment.crsrequest.'.$item} ne $newacc) {
+ $newenv{'environment.crsrequest.'.$item} = $newacc;
+ }
+ } else {
+ if ($env{'environment.availabletools.'.$item} ne $newacc) {
+ $newenv{'environment.availabletools.'.$item} = $newacc;
+ }
+ }
+ $resulttext .= '
'.$titles{$item}.'
';
+ foreach my $type (@{$types},'default','_LC_adv') {
+ if ($changes{$item}{$type}) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ } elsif ($type eq '_LC_adv') {
+ $typetitle = 'LON-CAPA Advanced Users';
+ }
+ if ($confhash{$item}{$type}) {
+ if ($context eq 'requestcourses') {
+ my $cond;
+ if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
+ if ($1 eq '') {
+ $cond = &mt('(Automatic processing of any request).');
+ } else {
+ $cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
+ }
+ } else {
+ $cond = $conditions{$confhash{$item}{$type}};
+ }
+ $resulttext .= '
'.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'
';
+ } else {
+ $resulttext .= '
'.&mt('Set to be available to [_1]',$typetitle).'
';
+ }
+ } else {
+ $resulttext .= '
'.&mt('Set to be unavailable to [_1]',$typetitle).'
';
+ }
+ }
}
- $resulttext .= '
'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'
';
+ $resulttext .= '
';
}
}
$resulttext .= '
';
+ if (keys(%newenv)) {
+ &Apache::lonnet::appenv(\%newenv);
+ }
} else {
- $resulttext = &mt('No changes made to default quotas');
+ if ($context eq 'requestcourses') {
+ $resulttext = &mt('No changes made to rights to request creation of courses.');
+ } else {
+ $resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
+ }
}
} else {
$resulttext = ''.
@@ -3708,7 +4277,7 @@ sub modify_contacts {
}
my (%others,%to);
my @contacts = ('supportemail','adminemail');
- my @mailings = ('errormail','packagesmail','helpdeskmail');
+ my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -3753,6 +4322,7 @@ sub modify_contacts {
$default{'errormail'} = 'adminemail';
$default{'packagesmail'} = 'adminemail';
$default{'helpdeskmail'} = 'supportemail';
+ $default{'lonstatusmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -3819,7 +4389,7 @@ sub modify_usercreation {
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
- my @contexts = ('author','course','selfcreate');
+ my @contexts = ('author','course','requestcrs','selfcreate');
foreach my $item(@contexts) {
if ($item eq 'selfcreate') {
@{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
@@ -3835,10 +4405,19 @@ sub modify_usercreation {
$cancreate{$item} = $env{'form.can_createuser_'.$item};
}
}
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ @{$cancreate{'statustocreate'}} =
+ &Apache::loncommon::get_env_multiple('form.statustocreate');
+ }
+ push(@contexts,'statustocreate');
+ }
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
- if ($item eq 'selfcreate') {
- if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
if (!grep(/^$curr$/,@{$cancreate{$item}})) {
if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
@@ -4014,16 +4593,65 @@ sub modify_usercreation {
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext = $lt{$type}.', ';
+ my $chgtext;
+ unless ($type eq 'statustocreate') {
+ $chgtext = $lt{$type}.', ';
+ }
if ($type eq 'selfcreate') {
if (@{$cancreate{$type}} == 0) {
$chgtext .= &mt('creation of a new user account is not permitted.');
} else {
- $chgtext .= &mt('creation of a new account is permitted for:
');
+ $chgtext .= &mt('creation of a new account is permitted for:').'
';
foreach my $case (@{$cancreate{$type}}) {
$chgtext .= '
'.$selfcreatetypes{$case}.'
';
}
$chgtext .= '
';
+ if (ref($cancreate{$type}) eq 'ARRAY') {
+ if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
+ if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+ $chgtext .= ' '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'';
+ }
+ }
+ }
+ }
+ }
+ } elsif ($type eq 'statustocreate') {
+ if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
+ (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
+ if (@{$cancreate{'selfcreate'}} > 0) {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'.");
+ if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ' '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'';
+ }
+ } elsif (ref($usertypes) eq 'HASH') {
+ if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
+ } else {
+ $chgtext .= &mt('Institutional affiliations permitted to create accounts with institutional authentication were set as follows:');
+ }
+ $chgtext .= '
';
+ foreach my $case (@{$cancreate{$type}}) {
+ if ($case eq 'default') {
+ $chgtext .= '
'.$othertitle.'
';
+ } else {
+ $chgtext .= '
'.$usertypes->{$case}.'
';
+ }
+ }
+ $chgtext .= '
';
+ if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ' '.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'';
+ }
+ }
+ } else {
+ if (@{$cancreate{$type}} == 0) {
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts were set to 'none'.");
+ } else {
+ $chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
+ }
+ }
}
} else {
if ($cancreate{$type} eq 'none') {
@@ -4248,7 +4876,7 @@ sub modify_defaults {
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
@@ -4275,20 +4903,24 @@ sub modify_defaults {
push(@errors,$item);
}
}
+ } elsif ($item eq 'datelocale_def') {
+ if ($newvalues{$item} ne '') {
+ my @datelocale_ids = DateTime::Locale->ids();
+ if (!grep(/^\Q$newvalues{$item}\E$/,@datelocale_ids)) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
+ $domdefaults{$item} = $newvalues{$item};
}
my %defaults_hash = (
- defaults => { auth_def => $newvalues{'auth_def'},
- auth_arg_def => $newvalues{'auth_arg_def'},
- lang_def => $newvalues{'lang_def'},
- timezone_def => $newvalues{'timezone_def'},
- }
- );
+ defaults => \%newvalues,
+ );
my $title = &defaults_titles();
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
$dom);
@@ -4317,9 +4949,8 @@ sub modify_defaults {
$resulttext .= '
';
$mailmsgtext .= "\n";
my $cachetime = 24*60*60;
- &Apache::lonnet::do_cache_new('domdefaults',$dom,
- $defaults_hash{'defaults'},$cachetime);
- if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'}) {
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
my $sysmail = $r->dir_config('lonSysEMail');
&Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
}
@@ -4437,8 +5068,10 @@ sub modify_coursecategories {
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
- $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
- $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
+ $domconfig{'coursecategories'} = {
+ togglecats => $env{'form.togglecats'},
+ categorize => $env{'form.categorize'},
+ };
}
if (ref($cathash) eq 'HASH') {
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
@@ -4600,6 +5233,131 @@ sub modify_coursecategories {
}
return $resulttext;
}
+
+sub modify_serverstatuses {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%changes,%currserverstatus,%newserverstatus);
+ if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
+ %currserverstatus = %{$domconfig{'serverstatuses'}};
+ }
+ my @pages = &serverstatus_pages();
+ foreach my $type (@pages) {
+ $newserverstatus{$type}{'namedusers'} = '';
+ $newserverstatus{$type}{'machines'} = '';
+ if (defined($env{'form.'.$type.'_namedusers'})) {
+ my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
+ my @okusers;
+ foreach my $user (@users) {
+ my ($uname,$udom) = split(/:/,$user);
+ if (($udom =~ /^$match_domain$/) &&
+ (&Apache::lonnet::domain($udom)) &&
+ ($uname =~ /^$match_username$/)) {
+ if (!grep(/^\Q$user\E/,@okusers)) {
+ push(@okusers,$user);
+ }
+ }
+ }
+ if (@okusers > 0) {
+ @okusers = sort(@okusers);
+ $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
+ }
+ }
+ if (defined($env{'form.'.$type.'_machines'})) {
+ my @machines = split(/,/,$env{'form.'.$type.'_machines'});
+ my @okmachines;
+ foreach my $ip (@machines) {
+ my @parts = split(/\./,$ip);
+ next if (@parts < 4);
+ my $badip = 0;
+ for (my $i=0; $i<4; $i++) {
+ if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
+ $badip = 1;
+ last;
+ }
+ }
+ if (!$badip) {
+ push(@okmachines,$ip);
+ }
+ }
+ @okmachines = sort(@okmachines);
+ $newserverstatus{$type}{'machines'} = join(',',@okmachines);
+ }
+ }
+ my %serverstatushash = (
+ serverstatuses => \%newserverstatus,
+ );
+ my %changes;
+ foreach my $type (@pages) {
+ foreach my $setting ('namedusers','machines') {
+ my (@current,@new);
+ if (ref($currserverstatus{$type}) eq 'HASH') {
+ if ($currserverstatus{$type}{$setting} ne '') {
+ @current = split(/,/,$currserverstatus{$type}{$setting});
+ }
+ }
+ if ($newserverstatus{$type}{$setting} ne '') {
+ @new = split(/,/,$newserverstatus{$type}{$setting});
+ }
+ if (@current > 0) {
+ if (@new > 0) {
+ foreach my $item (@current) {
+ if (!grep(/^\Q$item\E$/,@new)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ foreach my $item (@new) {
+ if (!grep(/^\Q$item\E$/,@current)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ } else {
+ $changes{$type}{$setting} = 1;
+ }
+ } elsif (@new > 0) {
+ $changes{$type}{$setting} = 1;
+ }
+ }
+ }
+ if (keys(%changes) > 0) {
+ my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
+ my $putresult = &Apache::lonnet::put_dom('configuration',
+ \%serverstatushash,$dom);
+ if ($putresult eq 'ok') {
+ $resulttext .= &mt('Changes made:').'
';
+ foreach my $type (@pages) {
+ if (ref($changes{$type}) eq 'HASH') {
+ $resulttext .= '
'.$titles->{$type}.'
';
+ if ($changes{$type}{'namedusers'}) {
+ if ($newserverstatus{$type}{'namedusers'} eq '') {
+ $resulttext .= '
'.&mt("Access terminated for all specific (named) users").'
'."\n";
+ } else {
+ $resulttext .= '
'.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'
'."\n";
+ }
+ }
+ if ($changes{$type}{'machines'}) {
+ if ($newserverstatus{$type}{'machines'} eq '') {
+ $resulttext .= '
'.&mt("Access terminated for all specific IP addresses").'
'."\n";
+ } else {
+ $resulttext .= '
'.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'
'."\n";
+ }
+
+ }
+ $resulttext .= '
';
+ }
+ }
+ $resulttext .= '
';
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'';
+
+ }
+ } else {
+ $resulttext = &mt('No changes made to access to server status pages');
+ }
+ return $resulttext;
+}
sub recurse_check {
my ($chkcats,$categories,$depth,$name) = @_;