';
+ '';
$rem = @fields%($numinrow);
}
my $colsleft = $numinrow - $rem;
@@ -7692,11 +7661,6 @@ 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'}.
#
@@ -7748,7 +7712,7 @@ sub modify_selfcreation {
# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts
# is permitted.
#
- foreach my $item ('login','sso','email') {
+ foreach my $item ('login','sso','email') {
if ($item eq 'email') {
if ($env{'form.cancreate_email'} eq 'email') {
push(@{$cancreate{'selfcreate'}},'email');
@@ -7764,22 +7728,20 @@ sub modify_selfcreation {
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.
+# Populate $cancreate{'emailusername'} hash ref with information types (if new user will provide data
+# value set to one), if self-creation with e-mail address permitted.
#
if (($env{'form.cancreate_email'} eq 'email') || ($env{'form.cancreate_email'} eq 'emailapproval')) {
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;
- }
- }
+ map { $userinfo{$_} = 1; } &Apache::loncommon::get_env_multiple('form.canmodify_emailusername');
+ if (ref($infofields) eq 'ARRAY') {
+ foreach my $field (@{$infofields}) {
+ if ($userinfo{$field}) {
+ $cancreate{'emailusername'}{$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
@@ -7838,6 +7800,7 @@ sub modify_selfcreation {
&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 ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -7850,12 +7813,14 @@ sub modify_selfcreation {
#
if (($env{'form.cancreate_login'}) || ($env{'form.cancreate_sso'})) {
if (ref($types) eq 'ARRAY') {
- if (@{$types} > 1) {
+ if (@{$types} > 0) {
@{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate');
push(@contexts,'statustocreate');
} else {
undef($cancreate{'statustocreate'});
}
+ push(@{$types},'default');
+ $usertypes->{'default'} = $othertitle;
foreach my $type (@{$types}) {
my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$type);
foreach my $field (@fields) {
@@ -7908,42 +7873,16 @@ sub modify_selfcreation {
} 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);
- }
- }
- }
- } else {
- if (!$cancreate{$item}{$curr}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
+ 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);
- }
- }
- }
- } else {
- if (!$curr_usercreation{'cancreate'}{$item}{$field}) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
- }
+ if (!$curr_usercreation{'cancreate'}{$item}{$field}) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
}
}
}
@@ -7963,19 +7902,8 @@ sub modify_selfcreation {
}
}
} 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;
- }
- }
- }
- }
+ if (keys(%userinfo) > 0) {
+ push(@{$changes{'cancreate'}},$item);
}
}
}
@@ -8105,23 +8033,17 @@ sub modify_selfcreation {
$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}).' ';
+ if (keys(%{$cancreate{'emailusername'}}) > 0) {
+ $chgtext .= &mt('When self-creating account with e-mail as username, user will provide the following information:').
+ '
';
+ foreach my $field (@{$infofields}) {
+ if ($cancreate{'emailusername'}{$field}) {
+ $chgtext .= '
'.$infotitles->{$field}.'
';
}
}
+ $chgtext .= '
';
+ } else {
+ $chgtext .= &mt('When self creating account with e-mail as username, user will not provide any information besides e-mail address');
}
}
} elsif ($type eq 'notify') {
@@ -8311,6 +8233,7 @@ sub modify_usermodification {
}
}
}
+# FIXME need to ensure selfcreate stuff is preserved
my %usermodification_hash = (
usermodification => \%modifyhash,
);