'.&mt('Validated course requests identified as processed by: [_1]',
- ''.$changes{'validation'}{'dc'}.'').'
';
- }
- }
- }
}
$resulttext .= '
';
if (keys(%newenv)) {
@@ -8032,38 +7315,106 @@ sub modify_contacts {
sub modify_usercreation {
my ($dom,%domconfig) = @_;
- my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate);
+ my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
my $warningmsg;
if (ref($domconfig{'usercreation'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'usercreation'}})) {
- if ($key eq 'cancreate') {
- if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') {
- foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
- if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
- ($item eq 'captcha') || ($item eq 'recaptchakeys')) {
- $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
- } else {
- $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
- }
- }
- }
- } elsif ($key eq 'email_rule') {
- $save_usercreate{$key} = $domconfig{'usercreation'}{$key};
- } else {
- $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
- }
+ $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
}
}
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
- my @contexts = ('author','course','requestcrs');
+ my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
+ my @contexts = ('author','course','requestcrs','selfcreate');
foreach my $item(@contexts) {
- $cancreate{$item} = $env{'form.can_createuser_'.$item};
+ if ($item eq 'selfcreate') {
+ @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
+ if (ref($cancreate{$item}) eq 'ARRAY') {
+ if (grep(/^login$/,@{$cancreate{$item}})) {
+ $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.&mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.');
+ }
+ }
+ }
+ } else {
+ $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');
+ } else {
+ @{$cancreate{'statustocreate'}} = ();
+ }
+ push(@contexts,'statustocreate');
}
+ &process_captcha('cancreate',\%changes,\%cancreate,\%curr_usercreation);
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
- if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
- push(@{$changes{'cancreate'}},$item);
+ if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
+ if (ref($cancreate{$item}) eq 'ARRAY') {
+ if (!grep(/^$curr$/,@{$cancreate{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} eq '') {
+ if (@{$cancreate{$item}} > 0) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} eq 'any') {
+ if (@{$cancreate{$item}} < 3) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') {
+ if (@{$cancreate{$item}} > 0) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ }
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ foreach my $type (@{$cancreate{$item}}) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') &&
+ ($curr_usercreation{'cancreate'}{$item} ne 'none')) {
+ if ($curr_usercreation{'cancreate'}{$item} ne $type) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
+ push(@{$changes{'cancreate'}},$item);
+ }
}
}
} elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
@@ -8114,6 +7465,21 @@ sub modify_usercreation {
push(@{$changes{'id_rule'}},@id_rule);
}
+ if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
+ foreach my $type (@{$curr_usercreation{'email_rule'}}) {
+ if (!grep(/^\Q$type\E$/,@email_rule)) {
+ push(@{$changes{'email_rule'}},$type);
+ }
+ }
+ foreach my $type (@email_rule) {
+ if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
+ push(@{$changes{'email_rule'}},$type);
+ }
+ }
+ } else {
+ push(@{$changes{'email_rule'}},@email_rule);
+ }
+
my @authen_contexts = ('author','course','domain');
my @authtypes = ('int','krb4','krb5','loc');
my %authhash;
@@ -8144,467 +7510,39 @@ sub modify_usercreation {
}
}
- $save_usercreate{'cancreate'}{'course'} = $cancreate{'course'};
- $save_usercreate{'cancreate'}{'author'} = $cancreate{'author'};
- $save_usercreate{'cancreate'}{'requestcrs'} = $cancreate{'requestcrs'};
- $save_usercreate{'id_rule'} = \@id_rule;
- $save_usercreate{'username_rule'} = \@username_rule,
- $save_usercreate{'authtypes'} = \%authhash;
-
my %usercreation_hash = (
- usercreation => \%save_usercreate,
- );
+ usercreation => {
+ cancreate => \%cancreate,
+ username_rule => \@username_rule,
+ id_rule => \@id_rule,
+ email_rule => \@email_rule,
+ authtypes => \%authhash,
+ }
+ );
my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
$dom);
- if ($putresult eq 'ok') {
- if (keys(%changes) > 0) {
- $resulttext = &mt('Changes made:').'
';
- if (ref($changes{'cancreate'}) eq 'ARRAY') {
- my %lt = &usercreation_types();
- foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext = $lt{$type}.', ';
- if ($cancreate{$type} eq 'none') {
- $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
- } elsif ($cancreate{$type} eq 'any') {
- $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
- } elsif ($cancreate{$type} eq 'official') {
- $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
- } elsif ($cancreate{$type} eq 'unofficial') {
- $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
- }
- $resulttext .= '
'.$chgtext.'
';
- }
- }
- if (ref($changes{'username_rule'}) eq 'ARRAY') {
- my ($rules,$ruleorder) =
- &Apache::lonnet::inst_userrules($dom,'username');
- my $chgtext = '
';
- foreach my $type (@username_rule) {
- if (ref($rules->{$type}) eq 'HASH') {
- $chgtext .= '
'.$rules->{$type}{'name'}.'
';
- }
- }
- $chgtext .= '
';
- if (@username_rule > 0) {
- $resulttext .= '
'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
';
- } else {
- $resulttext .= '
'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'
';
- }
- }
- if (ref($changes{'id_rule'}) eq 'ARRAY') {
- my ($idrules,$idruleorder) =
- &Apache::lonnet::inst_userrules($dom,'id');
- my $chgtext = '
';
- foreach my $type (@id_rule) {
- if (ref($idrules->{$type}) eq 'HASH') {
- $chgtext .= '
'.$idrules->{$type}{'name'}.'
';
- }
- }
- $chgtext .= '
';
- if (@id_rule > 0) {
- $resulttext .= '
'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
';
- } else {
- $resulttext .= '
'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'
';
- }
- }
- my %authname = &authtype_names();
- my %context_title = &context_names();
- if (ref($changes{'authtypes'}) eq 'ARRAY') {
- my $chgtext = '
';
- foreach my $type (@{$changes{'authtypes'}}) {
- my @allowed;
- $chgtext .= '
'.&mt('Authentication types available for assignment to new users').' '.$chgtext;
- $resulttext .= '
';
- }
- $resulttext .= '
';
- } else {
- $resulttext = &mt('No changes made to user creation settings');
- }
- } else {
- $resulttext = ''.
- &mt('An error occurred: [_1]',$putresult).'';
- }
- if ($warningmsg ne '') {
- $resulttext .= ' '.$warningmsg.' ';
- }
- return $resulttext;
-}
-
-sub modify_selfcreation {
- my ($dom,%domconfig) = @_;
- my ($resulttext,$warningmsg,%curr_usercreation,%curr_usermodify,%changes,%cancreate);
- my (%save_usercreate,%save_usermodify);
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- if (ref($types) eq 'ARRAY') {
- $usertypes->{'default'} = $othertitle;
- push(@{$types},'default');
- }
-#
-# Retrieve current domain configuration for self-creation of usernames from $domconfig{'usercreation'}.
-#
- if (ref($domconfig{'usercreation'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'usercreation'}})) {
- if ($key eq 'cancreate') {
- if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') {
- foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
- if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
- ($item eq 'captcha') || ($item eq 'recaptchakeys') ||
- ($item eq 'emailusername') || ($item eq 'notify') ||
- ($item eq 'selfcreateprocessing')) {
- $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
- } else {
- $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
- }
- }
- }
- } elsif ($key eq 'email_rule') {
- $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
- } else {
- $save_usercreate{$key} = $domconfig{'usercreation'}{$key};
- }
- }
- }
-#
-# Retrieve current domain configuration for self-creation of usernames from $domconfig{'usermodification'}.
-#
- if (ref($domconfig{'usermodification'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'usermodification'}})) {
- if ($key eq 'selfcreate') {
- $curr_usermodify{$key} = $domconfig{'usermodification'}{$key};
- } else {
- $save_usermodify{$key} = $domconfig{'usermodification'}{$key};
- }
- }
- }
-
- my @contexts = ('selfcreate');
- @{$cancreate{'selfcreate'}} = ();
- %{$cancreate{'emailusername'}} = ();
- @{$cancreate{'statustocreate'}} = ();
- %{$cancreate{'selfcreateprocessing'}} = ();
my %selfcreatetypes = (
sso => 'users authenticated by institutional single sign on',
login => 'users authenticated by institutional log-in',
- email => 'users who provide a valid e-mail address for use as username',
+ email => 'users who provide a valid e-mail address for use as the username',
);
-#
-# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts
-# is permitted.
-#
-
- my @statuses;
- if (ref($domconfig{'inststatus'}) eq 'HASH') {
- if (ref($domconfig{'inststatus'}{'inststatusguest'}) eq 'ARRAY') {
- @statuses = @{$domconfig{'inststatus'}{'inststatusguest'}};
- }
- }
- push(@statuses,'default');
-
- foreach my $item ('login','sso','email') {
- if ($item eq 'email') {
- if ($env{'form.cancreate_email'}) {
- push(@{$cancreate{'selfcreate'}},'email');
- push(@contexts,'selfcreateprocessing');
- foreach my $type (@statuses) {
- if ($type eq 'default') {
- $cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess'};
- } else {
- $cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess_'.$type};
- }
- }
- }
- } else {
- if ($env{'form.cancreate_'.$item}) {
- push(@{$cancreate{'selfcreate'}},$item);
- }
- }
- }
- my (@email_rule,%userinfo,%savecaptcha);
- my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
-#
-# Populate $cancreate{'emailusername'}{$type} hash ref with information fields (if new user will provide data
-# value set to one), if self-creation with e-mail address permitted, where $type is user type: faculty, staff, student etc.
-#
-
- if ($env{'form.cancreate_email'} eq 'email') {
- push(@contexts,'emailusername');
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
- if (ref($infofields) eq 'ARRAY') {
- foreach my $field (@{$infofields}) {
- if ($env{'form.canmodify_emailusername_'.$type.'_'.$field} =~ /^(required|optional)$/) {
- $cancreate{'emailusername'}{$type}{$field} = $1;
- }
- }
- }
- }
- }
-#
-# Populate $cancreate{'notify'} hash ref with names of Domain Coordinators who are to be notified of
-# queued requests for self-creation of account using e-mail address as username
-#
-
- my @approvalnotify = &Apache::loncommon::get_env_multiple('form.selfcreationnotifyapproval');
- @approvalnotify = sort(@approvalnotify);
- $cancreate{'notify'}{'approval'} = join(',',@approvalnotify);
- if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
- if (ref($curr_usercreation{'cancreate'}{'notify'}) eq 'HASH') {
- if ($curr_usercreation{'cancreate'}{'notify'}{'approval'} ne $cancreate{'notify'}{'approval'}) {
- push(@{$changes{'cancreate'}},'notify');
- }
- } else {
- if ($cancreate{'notify'}{'approval'}) {
- push(@{$changes{'cancreate'}},'notify');
- }
- }
- } elsif ($cancreate{'notify'}{'approval'}) {
- push(@{$changes{'cancreate'}},'notify');
- }
-
-#
-# Retrieve rules (if any) governing types of e-mail address which may be used as a username
-#
- @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
- &process_captcha('cancreate',\%changes,\%savecaptcha,$curr_usercreation{'cancreate'});
- if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
- if (@{$curr_usercreation{'email_rule'}} > 0) {
- foreach my $type (@{$curr_usercreation{'email_rule'}}) {
- if (!grep(/^\Q$type\E$/,@email_rule)) {
- push(@{$changes{'email_rule'}},$type);
- }
- }
- }
- if (@email_rule > 0) {
- foreach my $type (@email_rule) {
- if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
- push(@{$changes{'email_rule'}},$type);
- }
- }
- }
- } elsif (@email_rule > 0) {
- push(@{$changes{'email_rule'}},@email_rule);
- }
- }
-#
-# Check if domain default is set appropriately, if self-creation of accounts is to be available for
-# institutional log-in.
-#
- if (grep(/^login$/,@{$cancreate{'selfcreate'}})) {
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) ||
- ($domdefaults{'auth_def'} eq 'localauth'))) {
- $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.
- &mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.');
- }
- }
- my @fields = ('lastname','firstname','middlename','generation',
- 'permanentemail','id');
- my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
-#
-# Where usernames may created for institutional log-in and/or institutional single sign on:
-# (a) populate $cancreate{'statustocreate'} array reference with institutional status types who
-# may self-create accounts
-# (b) populate $save_usermodify{'selfcreate'} hash reference with status types, and information fields
-# which the user may supply, if institutional data is unavailable.
-#
- if (($env{'form.cancreate_login'}) || ($env{'form.cancreate_sso'})) {
- if (ref($types) eq 'ARRAY') {
- if (@{$types} > 1) {
- @{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate');
- push(@contexts,'statustocreate');
- } else {
- undef($cancreate{'statustocreate'});
- }
- foreach my $type (@{$types}) {
- my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$type);
- foreach my $field (@fields) {
- if (grep(/^\Q$field\E$/,@modifiable)) {
- $save_usermodify{'selfcreate'}{$type}{$field} = 1;
- } else {
- $save_usermodify{'selfcreate'}{$type}{$field} = 0;
- }
- }
- }
- if (ref($curr_usermodify{'selfcreate'}) eq 'HASH') {
- foreach my $type (@{$types}) {
- if (ref($curr_usermodify{'selfcreate'}{$type}) eq 'HASH') {
- foreach my $field (@fields) {
- if ($save_usermodify{'selfcreate'}{$type}{$field} ne
- $curr_usermodify{'selfcreate'}{$type}{$field}) {
- push(@{$changes{'selfcreate'}},$type);
- last;
- }
- }
- }
- }
- } else {
- foreach my $type (@{$types}) {
- push(@{$changes{'selfcreate'}},$type);
- }
- }
- }
- }
- foreach my $item (@contexts) {
- if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
- foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
- if (ref($cancreate{$item}) eq 'ARRAY') {
- if (!grep(/^$curr$/,@{$cancreate{$item}})) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- }
- if (ref($cancreate{$item}) eq 'ARRAY') {
- foreach my $type (@{$cancreate{$item}}) {
- if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- }
- } elsif (ref($curr_usercreation{'cancreate'}{$item}) eq 'HASH') {
- if (ref($cancreate{$item}) eq 'HASH') {
- foreach my $curr (keys(%{$curr_usercreation{'cancreate'}{$item}})) {
- if (ref($curr_usercreation{'cancreate'}{$item}{$curr}) eq 'HASH') {
- foreach my $field (keys(%{$curr_usercreation{'cancreate'}{$item}{$curr}})) {
- unless ($curr_usercreation{'cancreate'}{$item}{$curr}{$field} eq $cancreate{$item}{$curr}{$field}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- } elsif ($item eq 'selfcreateprocessing') {
- if ($cancreate{$item}{$curr} ne $curr_usercreation{'cancreate'}{$item}{$curr}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- } else {
- if (!$cancreate{$item}{$curr}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- }
- foreach my $field (keys(%{$cancreate{$item}})) {
- if (ref($cancreate{$item}{$field}) eq 'HASH') {
- foreach my $inner (keys(%{$cancreate{$item}{$field}})) {
- if (ref($curr_usercreation{'cancreate'}{$item}{$field}) eq 'HASH') {
- unless ($curr_usercreation{'cancreate'}{$item}{$field}{$inner} eq $cancreate{$item}{$field}{$inner}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- } else {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- } elsif ($item eq 'selfcreateprocessing') {
- if ($cancreate{$item}{$field} ne $curr_usercreation{'cancreate'}{$item}{$field}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- } else {
- if (!$curr_usercreation{'cancreate'}{$item}{$field}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- }
- }
- } elsif ($curr_usercreation{'cancreate'}{$item}) {
- if (ref($cancreate{$item}) eq 'ARRAY') {
- if (!grep(/^\Q$curr_usercreation{'cancreate'}{$item}\E$/,@{$cancreate{$item}})) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- } elsif (ref($cancreate{$item}) eq 'HASH') {
- if (!$cancreate{$item}{$curr_usercreation{'cancreate'}{$item}}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- }
- }
- } elsif ($item eq 'emailusername') {
- if (ref($cancreate{$item}) eq 'HASH') {
- foreach my $type (keys(%{$cancreate{$item}})) {
- if (ref($cancreate{$item}{$type}) eq 'HASH') {
- foreach my $field (keys(%{$cancreate{$item}{$type}})) {
- if ($cancreate{$item}{$type}{$field}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
- last;
- }
- }
- }
- }
- }
- }
- }
-#
-# Populate %save_usercreate hash with updates to self-creation configuration.
-#
- $save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'};
- $save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'};
- $save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'};
- if (ref($cancreate{'notify'}) eq 'HASH') {
- $save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'};
- }
- if (ref($cancreate{'selfcreateprocessing'}) eq 'HASH') {
- $save_usercreate{'cancreate'}{'selfcreateprocessing'} = $cancreate{'selfcreateprocessing'};
- }
- if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
- $save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'};
- }
- $save_usercreate{'cancreate'}{'emailusername'} = $cancreate{'emailusername'};
- $save_usercreate{'emailrule'} = \@email_rule;
-
- my %userconfig_hash = (
- usercreation => \%save_usercreate,
- usermodification => \%save_usermodify,
- );
- my $putresult = &Apache::lonnet::put_dom('configuration',\%userconfig_hash,
- $dom);
-#
-# Accumulate details of changes to domain cofiguration for self-creation of usernames in $resulttext
-#
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'
';
if (ref($changes{'cancreate'}) eq 'ARRAY') {
- my %lt = &selfcreation_types();
+ my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
my $chgtext;
+ unless (($type eq 'statustocreate') || ($type eq 'captcha') || ($type eq 'recaptchakeys')) {
+ $chgtext = $lt{$type}.', ';
+ }
if ($type eq 'selfcreate') {
if (@{$cancreate{$type}} == 0) {
- $chgtext .= &mt('Self creation of a new user account is not permitted.');
+ $chgtext .= &mt('creation of a new user account is not permitted.');
} else {
- $chgtext .= &mt('Self-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}.'
';
}
@@ -8613,10 +7551,7 @@ sub modify_selfcreation {
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.").
- '';
+ $chgtext .= ' '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'';
}
}
}
@@ -8627,13 +7562,11 @@ sub modify_selfcreation {
(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.").
- '';
- }
+ $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):');
@@ -8650,9 +7583,7 @@ sub modify_selfcreation {
}
$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.').
- '';
+ $chgtext .= ' '.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'';
}
}
} else {
@@ -8663,42 +7594,22 @@ sub modify_selfcreation {
}
}
}
- } elsif ($type eq 'selfcreateprocessing') {
- my %choices = &Apache::lonlocal::texthash (
- automatic => 'Automatic approval',
- approval => 'Queued for approval',
- );
- if (@statuses > 1) {
- $chgtext .= &mt('Processing of requests to create account with e-mail address as username set as follows:').
- '
';
- foreach my $type (@statuses) {
- if ($type eq 'default') {
- $chgtext .= '
';
- } else {
- $chgtext .= &mt('Processing of requests to create account with e-mail address as username set to: "[_1]"',
- $choices{$cancreate{'selfcreateprocessing'}{'default'}});
- }
} elsif ($type eq 'captcha') {
- if ($savecaptcha{$type} eq 'notused') {
+ if ($cancreate{$type} eq 'notused') {
$chgtext .= &mt('No CAPTCHA validation in use for self-creation screen.');
} else {
my %captchas = &captcha_phrases();
- if ($captchas{$savecaptcha{$type}}) {
- $chgtext .= &mt("Validation for self-creation screen set to $captchas{$savecaptcha{$type}}.");
+ if ($captchas{$cancreate{$type}}) {
+ $chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}.");
} else {
$chgtext .= &mt('Validation for self-creation screen set to unknown type.');
}
}
} elsif ($type eq 'recaptchakeys') {
my ($privkey,$pubkey);
- if (ref($savecaptcha{$type}) eq 'HASH') {
- $pubkey = $savecaptcha{$type}{'public'};
- $privkey = $savecaptcha{$type}{'private'};
+ if (ref($cancreate{$type}) eq 'HASH') {
+ $pubkey = $cancreate{$type}{'public'};
+ $privkey = $cancreate{$type}{'private'};
}
$chgtext .= &mt('ReCAPTCHA keys changes').'
';
if (!$pubkey) {
@@ -8712,41 +7623,51 @@ sub modify_selfcreation {
$chgtext .= '
'.&mt('Private key set to [_1]',$pubkey).'
';
}
$chgtext .= '
';
- } elsif ($type eq 'emailusername') {
- if (ref($cancreate{'emailusername'}) eq 'HASH') {
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
- if (ref($cancreate{'emailusername'}{$type}) eq 'HASH') {
- if (keys(%{$cancreate{'emailusername'}{$type}}) > 0) {
- $chgtext .= &mt('When self-creating account with e-mail as username, the following information will be provided by [_1]:',$usertypes->{$type}).
- '
';
- foreach my $field (@{$infofields}) {
- if ($cancreate{'emailusername'}{$type}{$field}) {
- $chgtext .= '
'.$infotitles->{$field}.'
';
- }
- }
- }
- $chgtext .= '
';
- } else {
- $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',$usertypes->{$type}).' ';
- }
- }
- }
- }
- } elsif ($type eq 'notify') {
- $chgtext = &mt('No Domain Coordinators will receive notification of username requests requiring approval.');
- if (ref($changes{'cancreate'}) eq 'ARRAY') {
- if ((grep(/^notify$/,@{$changes{'cancreate'}})) && (ref($cancreate{'notify'}) eq 'HASH')) {
- if ($cancreate{'notify'}{'approval'}) {
- $chgtext = &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'};
- }
- }
+ } else {
+ if ($cancreate{$type} eq 'none') {
+ $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
+ } elsif ($cancreate{$type} eq 'any') {
+ $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
+ } elsif ($cancreate{$type} eq 'official') {
+ $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
+ } elsif ($cancreate{$type} eq 'unofficial') {
+ $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
}
}
- if ($chgtext) {
- $resulttext .= '
'.$chgtext.'
';
+ $resulttext .= '
'.$chgtext.'
';
+ }
+ }
+ if (ref($changes{'username_rule'}) eq 'ARRAY') {
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'username');
+ my $chgtext = '
';
+ foreach my $type (@username_rule) {
+ if (ref($rules->{$type}) eq 'HASH') {
+ $chgtext .= '
'.$rules->{$type}{'name'}.'
';
}
}
+ $chgtext .= '
';
+ if (@username_rule > 0) {
+ $resulttext .= '
'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
';
+ } else {
+ $resulttext .= '
'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'
';
+ }
+ }
+ if (ref($changes{'id_rule'}) eq 'ARRAY') {
+ my ($idrules,$idruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'id');
+ my $chgtext = '
';
+ foreach my $type (@id_rule) {
+ if (ref($idrules->{$type}) eq 'HASH') {
+ $chgtext .= '
'.$idrules->{$type}{'name'}.'
';
+ }
+ }
+ $chgtext .= '
';
+ if (@id_rule > 0) {
+ $resulttext .= '
'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
';
+ } else {
+ $resulttext .= '
'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'
';
+ }
}
if (ref($changes{'email_rule'}) eq 'ARRAY') {
my ($emailrules,$emailruleorder) =
@@ -8759,48 +7680,37 @@ sub modify_selfcreation {
}
$chgtext .= '
';
if (@email_rule > 0) {
- $resulttext .= '
'.
- &mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').
- $chgtext.
- '
';
+ $resulttext .= '
'.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'
';
} else {
- $resulttext .= '
'.
- &mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').
- '
';
+ $resulttext .= '
'.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'