--- loncom/interface/domainprefs.pm 2017/06/05 21:12:05 1.301
+++ loncom/interface/domainprefs.pm 2017/07/26 19:45:45 1.303
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.301 2017/06/05 21:12:05 raeburn Exp $
+# $Id: domainprefs.pm,v 1.303 2017/07/26 19:45:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -281,7 +281,7 @@ sub handler {
{col1 => 'Internal Authentication',
col2 => 'Value'},
{col1 => 'Institutional user types',
- col2 => 'Assignable to e-mail usernames'}],
+ col2 => 'Assignable to non-institutional users'}],
print => \&print_defaults,
modify => \&modify_defaults,
},
@@ -363,7 +363,7 @@ sub handler {
col2 => 'Enabled?'},
{col1 => 'Institutional user type (login/SSO self-creation)',
col2 => 'Information user can enter'},
- {col1 => 'Self-creation with e-mail as username',
+ {col1 => 'Self-creation with e-mail verification',
col2 => 'Settings'}],
print => \&print_selfcreation,
modify => \&modify_selfcreation,
@@ -5390,9 +5390,14 @@ sub loadbalancing_titles {
'_LC_ipchange' => &mt('Non-SSO users with IP mismatch'),
);
my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange');
+ my @available;
if (ref($types) eq 'ARRAY') {
- unshift(@alltypes,@{$types},'default');
+ @available = @{$types};
}
+ unless (grep(/^default$/,@available)) {
+ push(@available,'default');
+ }
+ unshift(@alltypes,@available);
my %titles;
foreach my $type (@alltypes) {
if ($type =~ /^_LC_/) {
@@ -5747,7 +5752,7 @@ sub print_usercreation {
sub print_selfcreation {
my ($position,$dom,$settings,$rowtotal) = @_;
- my (@selfcreate,$createsettings,$processing,$datatable);
+ my (@selfcreate,$createsettings,$processing,$emailverified,$emaildomain,$datatable);
if (ref($settings) eq 'HASH') {
if (ref($settings->{'cancreate'}) eq 'HASH') {
$createsettings = $settings->{'cancreate'};
@@ -5764,12 +5769,19 @@ sub print_selfcreation {
if (ref($createsettings->{'selfcreateprocessing'}) eq 'HASH') {
$processing = $createsettings->{'selfcreateprocessing'};
}
+ if (ref($createsettings->{'emailverified'}) eq 'HASH') {
+ $emailverified = $createsettings->{'emailverified'};
+ }
+ if (ref($createsettings->{'emaildomain'}) eq 'HASH') {
+ $emaildomain = $createsettings->{'emaildomain'};
+ }
}
}
}
my %radiohash;
my $numinrow = 4;
map { $radiohash{'cancreate_'.$_} = 1; } @selfcreate;
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
if ($position eq 'top') {
my %choices = &Apache::lonlocal::texthash (
cancreate_login => 'Institutional Login',
@@ -5785,8 +5797,6 @@ sub print_selfcreation {
\%choices,$itemcount,$onclick);
$$rowtotal += $itemcount;
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
-
if (ref($usertypes) eq 'HASH') {
if (keys(%{$usertypes}) > 0) {
$datatable .= &insttypes_row($createsettings,$types,$usertypes,
@@ -5836,20 +5846,26 @@ sub print_selfcreation {
$$rowtotal ++;
} elsif ($position eq 'middle') {
my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom);
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- $usertypes->{'default'} = $othertitle;
+ my @posstypes;
if (ref($types) eq 'ARRAY') {
- push(@{$types},'default');
- $usertypes->{'default'} = $othertitle;
- foreach my $status (@{$types}) {
- $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
- $numinrow,$$rowtotal,$usertypes);
- $$rowtotal ++;
- }
+ @posstypes = @{$types};
+ }
+ unless (grep(/^default$/,@posstypes)) {
+ push(@posstypes,'default');
+ }
+ my %usertypeshash;
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ $usertypeshash{'default'} = $othertitle;
+ foreach my $status (@posstypes) {
+ $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
+ $numinrow,$$rowtotal,\%usertypeshash);
+ $$rowtotal ++;
}
} else {
my %choices = &Apache::lonlocal::texthash (
- cancreate_email => 'E-mail address as username',
+ cancreate_email => 'Non-institutional username (e-mail verification)',
);
my @toggles = sort(keys(%choices));
my %defaultchecked = (
@@ -5863,29 +5879,45 @@ sub print_selfcreation {
my $onclick = "toggleDisplay(this.form,'emailoptions');";
my $additional = '
';
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my $usertypes = {};
- my $order = [];
- if ((ref($domdefaults{'inststatustypes'}) eq 'HASH') && (ref($domdefaults{'inststatusguest'}) eq 'ARRAY')) {
- $usertypes = $domdefaults{'inststatustypes'};
+ my $order;
+ if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') {
$order = $domdefaults{'inststatusguest'};
}
+ my (@ordered,%usertypeshash);
if (ref($order) eq 'ARRAY') {
- push(@{$order},'default');
- if (@{$order} > 1) {
- $usertypes->{'default'} = &mt('Other users');
- $additional .= '
';
- foreach my $status (@{$order}) {
- $additional .= ''.$usertypes->{$status}.' ';
- }
- $additional .= ' ';
- foreach my $status (@{$order}) {
- $additional .= ''.&email_as_username($rowtotal,$processing,$status).' ';
- }
- $additional .= '
';
- } else {
- $usertypes->{'default'} = &mt('All users');
- $additional .= &email_as_username($rowtotal,$processing);
+ @ordered = @{$order};
+ }
+ if (@ordered) {
+ unless (grep(/^default$/,@ordered)) {
+ push(@ordered,'default');
}
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ $usertypeshash{'default'} = $othertitle;
+ $additional .= '
';
+ foreach my $status (@ordered) {
+ $additional .= ''.$usertypeshash{$status}.' ';
+ }
+ $additional .= ' ';
+ foreach my $status (@ordered) {
+ $additional .= ''.&validate_by_email($rowtotal,$processing,$status).' ';
+ }
+ $additional .= '
'.
+ '
';
+ foreach my $status (@ordered) {
+ $additional .= ''.$usertypeshash{$status}.' ';
+ }
+ $additional .= ' ';
+ foreach my $status (@ordered) {
+ $additional .= ''.&email_as_username($rowtotal,$emailverified,$emaildomain,$status).' ';
+ }
+ $additional .= '
';
+
+ } else {
+ $usertypeshash{'default'} = $othertitle;
+ $additional .= &mt('Approval:').' '.&validate_by_email($rowtotal,$processing).'
'.
+ &mt('Username:').' '.&email_as_username($rowtotal,$emailverified,$emaildomain);
}
$additional .= '
'."\n";
@@ -5896,12 +5928,10 @@ sub print_selfcreation {
$$rowtotal ++;
my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
$numinrow = 1;
- if (ref($order) eq 'ARRAY') {
- foreach my $status (@{$order}) {
- $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
- $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles);
- $$rowtotal ++;
- }
+ foreach my $status (@ordered) {
+ $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
+ $numinrow,$$rowtotal,\%usertypeshash,$infofields,$infotitles);
+ $$rowtotal ++;
}
my ($emailrules,$emailruleorder) =
&Apache::lonnet::inst_userrules($dom,'email');
@@ -5917,15 +5947,20 @@ sub print_selfcreation {
return $datatable;
}
-sub email_as_username {
+sub validate_by_email {
my ($rowtotal,$processing,$type) = @_;
my %choices =
&Apache::lonlocal::texthash (
automatic => 'Automatic approval',
approval => 'Queued for approval',
+ notinuse => 'Unavailable',
);
my $output;
- foreach my $option ('automatic','approval') {
+ my @options = ('automatic','approval');
+ unless ($type eq '') {
+ push(@options,'notinuse');
+ }
+ foreach my $option (@options) {
my $checked;
if (ref($processing) eq 'HASH') {
if ($type eq '') {
@@ -5970,6 +6005,83 @@ sub email_as_username {
return $output;
}
+sub email_as_username {
+ my ($rowtotal,$emailverified,$emaildomain,$type) = @_;
+ my %choices =
+ &Apache::lonlocal::texthash (
+ email => 'Username is e-mail',
+ other => 'Username is chosen',
+ );
+ my $name = 'cancreate_emailverified';
+ my $condition = 'cancreate_emaildomain';
+ if (($type ne '') && ($type ne 'default')) {
+ $name .= '_'.$type;
+ $condition .= '_'.$type;
+ }
+ my $display = 'none';
+ my $onclick = "toggleDisplay(this.form,'$name');";
+
+ my $output;
+ foreach my $option ('email','other') {
+ my ($checked,$domain);
+ if (ref($emailverified) eq 'HASH') {
+ if ($type eq '') {
+ if (!exists($emailverified->{'default'})) {
+ if ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($emailverified->{'default'} eq $option) {
+ $checked = ' checked="checked"';
+ }
+ }
+ } else {
+ if (!exists($emailverified->{$type})) {
+ if ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($emailverified->{$type} eq $option) {
+ $checked = ' checked="checked"';
+ if ($option eq 'other') {
+ $display = 'inline';
+ }
+ }
+ }
+ }
+ } elsif ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ $output .= ''.
+ ' '.
+ $choices{$option}.' ';
+ if ($type eq '') {
+ $output .= ' ';
+ } else {
+ $output .= ' ';
+ }
+ }
+ my $domain;
+ if (ref($emaildomain) eq 'HASH') {
+ if ($type eq '') {
+ if (exists($emaildomain->{'default'})) {
+ $domain = $emaildomain->{'default'};
+ }
+ } else {
+ if (exists($emaildomain->{$type})) {
+ $domain = $emaildomain->{$type};
+ }
+ }
+ }
+ $output .= ''.
+ ''.&mt('E-mail domain').' '.
+ ' '.
+ '
';
+ $$rowtotal ++;
+ return $output;
+}
+
sub captcha_choice {
my ($context,$settings,$itemcount) = @_;
my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
@@ -10946,12 +11058,10 @@ sub modify_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 'recaptchaversion')) {
- $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
- } else {
+ if (($item eq 'requestcrs') || ($item eq 'course') || ($item eq 'author')) {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
+ } else {
+ $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
}
}
}
@@ -11156,12 +11266,18 @@ sub modify_usercreation {
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');
+ my (%save_usercreate,%save_usermodify,@types,%usertypes);
+ my ($othertitle,$usertypesref,$typesref) = &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($typesref) eq 'ARRAY') {
+ @types = @{$typesref};
}
+ unless (grep(/^default$/,@types)) {
+ push(@types,'default');
+ }
+ if (ref($usertypesref) eq 'HASH') {
+ %usertypes = %{$usertypesref};
+ }
+ $usertypes{'default'} = $othertitle;
#
# Retrieve current domain configuration for self-creation of usernames from $domconfig{'usercreation'}.
#
@@ -11171,10 +11287,11 @@ sub modify_selfcreation {
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 'recaptchaversion') ||
- ($item eq 'emailusername') || ($item eq 'notify') ||
- ($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) {
+ ($item eq 'captcha') || ($item eq 'recaptchakeys') ||
+ ($item eq 'recaptchaversion') || ($item eq 'notify') ||
+ ($item eq 'emailusername') || ($item eq 'shibenv') ||
+ ($item eq 'selfcreateprocessing') || ($item eq 'emailverified') ||
+ ($item eq 'emaildomain')) {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
} else {
$save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -11207,10 +11324,12 @@ sub modify_selfcreation {
@{$cancreate{'statustocreate'}} = ();
%{$cancreate{'selfcreateprocessing'}} = ();
%{$cancreate{'shibenv'}} = ();
+ %{$cancreate{'emailverified'}} = ();
+ %{$cancreate{'emaildomain'}} = ();
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 verified by e-mail',
);
#
# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts
@@ -11229,12 +11348,22 @@ sub modify_selfcreation {
if ($item eq 'email') {
if ($env{'form.cancreate_email'}) {
push(@{$cancreate{'selfcreate'}},'email');
- push(@contexts,'selfcreateprocessing');
+ push(@contexts,('selfcreateprocessing','emailverified','emaildomain'));
foreach my $type (@statuses) {
if ($type eq 'default') {
$cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess'};
+ unless ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') {
+ $cancreate{'emailverified'}{$type} = $env{'form.cancreate_emailverified'};
+ if ($cancreate{'emailverified'}{$type} eq 'other') {
+ $cancreate{'emaildomain'}{$type} =$env{'form.cancreate_emaildomain'};
+ }
+ }
} else {
$cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess_'.$type};
+ $cancreate{'emailverified'}{$type} = $env{'form.cancreate_emailverified_'.$type};
+ if ($cancreate{'emailverified'}{$type} eq 'other') {
+ $cancreate{'emaildomain'}{$type} =$env{'form.cancreate_emaildomain_'.$type};
+ }
}
}
}
@@ -11253,8 +11382,8 @@ sub modify_selfcreation {
if ($env{'form.cancreate_email'}) {
push(@contexts,'emailusername');
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
+ if (@types) {
+ foreach my $type (@types) {
if (ref($infofields) eq 'ARRAY') {
foreach my $field (@{$infofields}) {
if ($env{'form.canmodify_emailusername_'.$type.'_'.$field} =~ /^(required|optional)$/) {
@@ -11266,7 +11395,7 @@ sub modify_selfcreation {
}
#
# 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
+# queued requests for self-creation of account verified by e-mail.
#
my @approvalnotify = &Apache::loncommon::get_env_multiple('form.selfcreationnotifyapproval');
@@ -11287,7 +11416,7 @@ sub modify_selfcreation {
}
#
-# Retrieve rules (if any) governing types of e-mail address which may be used as a username
+# Retrieve rules (if any) governing types of e-mail address which may be used to verify a username.
#
@email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
&process_captcha('cancreate',\%changes,\%savecaptcha,$curr_usercreation{'cancreate'});
@@ -11334,14 +11463,14 @@ sub modify_selfcreation {
# 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) {
+ if (@types) {
+ if (@types > 1) {
@{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate');
push(@contexts,'statustocreate');
} else {
undef($cancreate{'statustocreate'});
}
- foreach my $type (@{$types}) {
+ foreach my $type (@types) {
my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$type);
foreach my $field (@fields) {
if (grep(/^\Q$field\E$/,@modifiable)) {
@@ -11352,7 +11481,7 @@ sub modify_selfcreation {
}
}
if (ref($curr_usermodify{'selfcreate'}) eq 'HASH') {
- foreach my $type (@{$types}) {
+ foreach my $type (@types) {
if (ref($curr_usermodify{'selfcreate'}{$type}) eq 'HASH') {
foreach my $field (@fields) {
if ($save_usermodify{'selfcreate'}{$type}{$field} ne
@@ -11364,7 +11493,7 @@ sub modify_selfcreation {
}
}
} else {
- foreach my $type (@{$types}) {
+ foreach my $type (@types) {
push(@{$changes{'selfcreate'}},$type);
}
}
@@ -11422,7 +11551,7 @@ sub modify_selfcreation {
}
}
}
- } elsif ($item eq 'selfcreateprocessing') {
+ } elsif (($item eq 'selfcreateprocessing') || ($item eq 'emailverified') || ($item eq 'emaildomain')) {
if ($cancreate{$item}{$curr} ne $curr_usercreation{'cancreate'}{$item}{$curr}) {
if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
push(@{$changes{'cancreate'}},$item);
@@ -11510,6 +11639,12 @@ sub modify_selfcreation {
if (ref($cancreate{'selfcreateprocessing'}) eq 'HASH') {
$save_usercreate{'cancreate'}{'selfcreateprocessing'} = $cancreate{'selfcreateprocessing'};
}
+ if (ref($cancreate{'emailverified'}) eq 'HASH') {
+ $save_usercreate{'cancreate'}{'emailverified'} = $cancreate{'emailverified'};
+ }
+ if (ref($cancreate{'emaildomain'}) eq 'HASH') {
+ $save_usercreate{'cancreate'}{'emaildomain'} = $cancreate{'emaildomain'};
+ }
if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
$save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'};
}
@@ -11534,7 +11669,7 @@ sub modify_selfcreation {
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &selfcreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext;
+ my $chgtext = '';
if ($type eq 'selfcreate') {
if (@{$cancreate{$type}} == 0) {
$chgtext .= &mt('Self creation of a new user account is not permitted.');
@@ -11549,10 +11684,25 @@ 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 via log-in or single sign-on.").
+ ' ';
+ }
+ }
+ }
+ if (grep(/^email$/,@{$cancreate{$type}})) {
+ if (@statuses > 1) {
+ my $numtypes = 0;
+ foreach my $type (@statuses) {
+ unless ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') {
+ $numtypes ++;
+ }
+ }
+ if (!$numtypes) {
+ $chgtext .= ''.
+ &mt("However, e-mail verification is currently set to 'unavailable' for all user types (including 'other'), so self-creation of accounts is not possible for non-institutional log-in.").
+ ' ';
+
}
}
}
@@ -11560,7 +11710,7 @@ sub modify_selfcreation {
}
} elsif ($type eq 'shibenv') {
if (keys(%{$cancreate{$type}}) == 0) {
- $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information');
+ $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information').' ';
} else {
$chgtext .= &mt('Shibboleth-autheticated user information set from environment variables, as follows:').
'';
@@ -11573,7 +11723,7 @@ sub modify_selfcreation {
}
}
$chgtext .= ' ';
- }
+ }
} elsif ($type eq 'statustocreate') {
if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
(ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
@@ -11586,7 +11736,7 @@ sub modify_selfcreation {
&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").
'';
}
- } elsif (ref($usertypes) eq 'HASH') {
+ } elsif (keys(%usertypes) > 0) {
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 {
@@ -11597,12 +11747,12 @@ sub modify_selfcreation {
if ($case eq 'default') {
$chgtext .= ''.$othertitle.' ';
} else {
- $chgtext .= ''.$usertypes->{$case}.' ';
+ $chgtext .= ''.$usertypes{$case}.' ';
}
}
$chgtext .= '';
if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
- $chgtext .= ''.
+ $chgtext .= ''.
&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').
' ';
}
@@ -11614,26 +11764,109 @@ sub modify_selfcreation {
$chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
}
}
+ $chgtext .= ' ';
}
} elsif ($type eq 'selfcreateprocessing') {
my %choices = &Apache::lonlocal::texthash (
automatic => 'Automatic approval',
approval => 'Queued for approval',
+ notinuse => 'Unavailable',
);
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 .= ''.$othertitle.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.' ';
- } else {
- $chgtext .= ''.$usertypes->{$type}.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.' ';
- }
- }
- $chgtext .= ' ';
+ my $numtypes = 0;
+ foreach my $type (@statuses) {
+ unless ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') {
+ $numtypes ++;
+ }
+ }
+ if ($numtypes) {
+ $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:').
+ '';
+ foreach my $type (@statuses) {
+ if ($type eq 'default') {
+ $chgtext .= ''.$othertitle.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.' ';
+ } else {
+ $chgtext .= ''.$usertypes{$type}.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.' ';
+ }
+ }
+ $chgtext .= ' ';
+ }
} else {
- $chgtext .= &mt('Processing of requests to create account with e-mail address as username set to: "[_1]"',
- $choices{$cancreate{'selfcreateprocessing'}{'default'}});
+ $chgtext .= &mt('Processing of requests to create account with e-mail verification set to: "[_1]"',
+ $choices{$cancreate{'selfcreateprocessing'}{'default'}});
+ }
+ } elsif ($type eq 'emailverified') {
+ my %options = &Apache::lonlocal::texthash (
+ email => 'Username is e-mail',
+ other => 'Username is chosen',
+ );
+ if (@statuses > 1) {
+ my $numtypes = 0;
+ foreach my $type (@statuses) {
+ unless ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') {
+ $numtypes ++;
+ }
+ }
+ if ($numtypes) {
+ $chgtext .= &mt('For self-created accounts verified by e-mail address, username is set as follows:').
+ '';
+ foreach my $type (@statuses) {
+ next if ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse');
+ if ($type eq 'default') {
+ $chgtext .= ''.$othertitle.' -- '.$options{$cancreate{'emailverified'}{$type}}.' ';
+ } else {
+ $chgtext .= ''.$usertypes{$type}.' -- '.$options{$cancreate{'emailverified'}{$type}}.' ';
+ }
+ }
+ $chgtext .= ' ';
+ }
+ } else {
+ $chgtext .= &mt('For self-created accounts verified by e-mail address: "[_1]"',
+ $choices{$cancreate{'emailverified'}{'default'}});
+ }
+ } elsif ($type eq 'emaildomain') {
+ if (@statuses > 1) {
+ my $numtypes = 0;
+ foreach my $type (@statuses) {
+ unless ($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') {
+ if ($cancreate{'emailverified'}{$type} eq 'other') {
+ $numtypes ++;
+ }
+ }
+ }
+ if ($numtypes) {
+ $chgtext .= &mt('For self-created accounts verified by e-mail address, with username chosen by user ...').
+ '';
+ foreach my $type (@statuses) {
+ next if (($cancreate{'selfcreateprocessing'}{$type} eq 'notinuse') ||
+ ($cancreate{'emailverified'}{$type} eq 'email'));
+ if ($type eq 'default') {
+ if ($cancreate{'emaildomain'}{$type} eq '') {
+ $chgtext .= ''.$othertitle.' -- '.&mt('No restriction on e-mail domain').' ';
+ } else {
+ $chgtext .= ''.$othertitle.' -- '.&mt("User's e-mail domain needs to be: [_1]",
+ $cancreate{'emaildomain'}{$type}).' ';
+ }
+ } else {
+ if ($cancreate{'emaildomain'}{$type} eq '') {
+ $chgtext .= ''.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').' ';
+ } else {
+ $chgtext .= ''.$usertypes{$type}.' -- '.&mt("User's e-mail domain needs to be: [_1]",
+ $cancreate{'emaildomain'}{$type}).' ';
+ }
+ }
+ }
+ $chgtext .= ' ';
+ }
+ } else {
+ if ($cancreate{'emailverified'}{'default'} eq 'other') {
+ if ($cancreate{'emaildomain'}{'default'} eq '') {
+ $chgtext .= &mt('No restriction on e-mail domain for self-created accounts verified by e-mail address, where username is chosen by user.');
+ } else {
+ $chgtext .= &mt('For self-created accounts verified by e-mail address, where username is chosen by user, e-mail domain needs to be: [_1],
+ $cancreate{'selfcreateprocessing'}{'default'});
+ }
+ }
}
} elsif ($type eq 'captcha') {
if ($savecaptcha{$type} eq 'notused') {
@@ -11670,11 +11903,11 @@ sub modify_selfcreation {
}
} elsif ($type eq 'emailusername') {
if (ref($cancreate{'emailusername'}) eq 'HASH') {
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
+ if (@types) {
+ 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}'").
+ $chgtext .= &mt('When self-creating account with e-mail verification, the following information will be provided by [_1]:',"'$usertypes{$type}'").
'';
foreach my $field (@{$infofields}) {
if ($cancreate{'emailusername'}{$type}{$field}) {
@@ -11683,23 +11916,27 @@ sub modify_selfcreation {
}
$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}'").' ';
+ $chgtext .= &mt('When self creating account with e-mail verification, no information besides e-mail address will be provided by [_1].',"'$usertypes{$type}'").' ';
}
} 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}'").' ';
+ $chgtext .= &mt('When self creating account with e-mail verification, 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.');
+ my $numapprove = 0;
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'};
+ $chgtext .= &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'};
+ $numapprove ++;
}
}
}
+ unless ($numapprove) {
+ $chgtext .= &mt('No Domain Coordinators will receive notification of username requests requiring approval.');
+ }
}
if ($chgtext) {
$resulttext .= ''.$chgtext.' ';
@@ -11718,12 +11955,12 @@ 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: ').
+ &mt('Accounts may not be created by users verified by e-mail, for 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.').
+ &mt('There are now no restrictions on e-mail addresses which may be used for verification when self-enrolling.').
' ';
}
}
@@ -11732,9 +11969,9 @@ sub modify_selfcreation {
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
foreach my $type (@{$changes{'selfcreate'}}) {
my $typename = $type;
- if (ref($usertypes) eq 'HASH') {
- if ($usertypes->{$type} ne '') {
- $typename = $usertypes->{$type};
+ if (keys(%usertypes) > 0) {
+ if ($usertypes{$type} ne '') {
+ $typename = $usertypes{$type};
}
}
my @modifiable;
@@ -15235,6 +15472,7 @@ function toggleDisplay(domForm,caller) {
var optionsElement = domForm.coursecredits;
var checkval = 1;
var dispval = 'block';
+ var selfcreateRegExp = /^cancreate_emailverified/;
if (caller == 'emailoptions') {
optionsElement = domForm.cancreate_email;
}
@@ -15245,6 +15483,11 @@ function toggleDisplay(domForm,caller) {
optionsElement = domForm.canclone;
checkval = 'instcode';
}
+ if (selfcreateRegExp.test(caller)) {
+ optionsElement = domForm.elements[caller];
+ checkval = 'other';
+ dispval = 'inline'
+ }
if (optionsElement.length) {
var currval;
for (var i=0; i