--- loncom/interface/domainprefs.pm 2014/01/06 14:08:31 1.160.6.33 +++ loncom/interface/domainprefs.pm 2014/02/15 17:07:19 1.160.6.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.33 2014/01/06 14:08:31 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.34 2014/02/15 17:07:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -95,7 +95,7 @@ institutional affiliation in the domain 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, and to display/store -default quota sizes for authoring spaces. +default quota sizes for Authoring Spaces. Outputs: 1 @@ -215,7 +215,7 @@ sub handler { 'usersessions','loadbalancing','requestauthor'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', - 'usercreation','usermodification','scantron', + 'usercreation','selfcreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', 'serverstatuses','coursedefaults','usersessions'); my %existing; @@ -293,7 +293,6 @@ sub handler { header => [{col1 => 'Setting', col2 => 'Value',}], }, - 'usercreation' => { text => 'User creation', help => 'Domain_Configuration_User_Creation', @@ -304,15 +303,23 @@ sub handler { {col1 => 'Context', col2 => 'Assignable authentication types'}], }, + 'selfcreation' => + { text => 'Users self-creating accounts', + help => 'Domain_Configuration_Self_Creation', + header => [{col1 => 'Self-creation with institutional username', + col2 => 'Enabled?'}, + {col1 => 'Institutional user type (login/SSO self-creation)', + col2 => 'Information user can enter'}, + {col1 => 'Self-creation with e-mail as username', + col2 => 'Settings'}], + }, 'usermodification' => { text => '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', - col2 => 'User information updateable in course context'}, - {col1 => "Status of user", - col2 => 'Information settable when self-creating account (if directory data blank)'}], + col2 => 'User information updateable in course context'}], }, 'scantron' => { text => 'Bubblesheet format file', @@ -332,7 +339,7 @@ sub handler { col2 => ''}], }, 'requestauthor' => - {text => 'Request authoring space', + {text => 'Request Authoring Space', help => 'Domain_Configuration_Request_Author', header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, @@ -522,6 +529,8 @@ sub process_changes { $output = &modify_directorysrch($dom,%domconfig); } elsif ($action eq 'usercreation') { $output = &modify_usercreation($dom,%domconfig); + } elsif ($action eq 'selfcreation') { + $output = &modify_selfcreation($dom,%domconfig); } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { @@ -590,6 +599,8 @@ sub print_config_box { $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'usercreation') { $output .= &print_usercreation('top',$dom,$settings,\$rowtotal); + } elsif ($action eq 'selfcreation') { + $output .= &print_selfcreation('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'usermodification') { $output .= &print_usermodification('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { @@ -649,8 +660,8 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col2'}).' '. &print_usercreation('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif ($action eq 'usermodification') { - $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).' + } elsif ($action eq 'selfcreation') { + $output .= &print_selfcreation('middle',$dom,$settings,\$rowtotal).' @@ -659,9 +670,12 @@ sub print_config_box { - '. - &print_usermodification('bottom',$dom,$settings,\$rowtotal); + + '. + &print_selfcreation('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; + } elsif ($action eq 'usermodification') { + $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { @@ -1972,23 +1986,26 @@ sub print_requestmail { if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); + map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); } } } my $numinrow = 2; - my $css_class = 'class="LC_odd_row"'; + my $css_class; + $css_class = ($$rowtotal%2? ' class="LC_odd_row"':''); my $text; if ($action eq 'requestcourses') { $text = &mt('Receive notification of course requests requiring approval'); + } elsif ($action eq 'requestauthor') { + $text = &mt('Receive notification of Authoring Space requests requiring approval'); } else { - $text = &mt('Receive notification of authoring space requests requiring approval') + $text = &mt('Receive notification of queued requests for self-created user accounts requiring approval'); } - $datatable = ''. + $datatable = ''. ' '. ' '; $$rowtotal ++; $rowcount ++; } } elsif ($position eq 'middle') { - my @creators = ('author','course','requestcrs','selfcreate'); + my @creators = ('author','course','requestcrs'); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); my %lt = &usercreation_types(); my %checked; - my @selfcreate; if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { foreach my $item (@creators) { $checked{$item} = $settings->{'cancreate'}{$item}; } - if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') { - @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}}; - } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') { - if ($settings->{'cancreate'}{'selfcreate'} eq 'any') { - @selfcreate = ('email','login','sso'); - } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') { - @selfcreate = ($settings->{'cancreate'}{'selfcreate'}); - } - } } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') { foreach my $item (@creators) { if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) { @@ -3678,10 +3675,8 @@ sub print_usercreation { my $rownum = 0; foreach my $item (@creators) { $rownum ++; - if ($item ne 'selfcreate') { - if ($checked{$item} eq '') { - $checked{$item} = 'any'; - } + if ($checked{$item} eq '') { + $checked{$item} = 'any'; } my $css_class; if ($rownum%2) { @@ -3692,30 +3687,18 @@ sub print_usercreation { $datatable .= ''. ''. + &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal); + $rownum ++; + my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); + $numinrow = 2; + $datatable .= &modifiable_userdata_row('cancreate','emailusername',$settings, + $numinrow,$rownum,undef,$infofields,$infotitles); + $$rowtotal ++; + $rownum ++; + my ($emailrules,$emailruleorder) = + &Apache::lonnet::inst_userrules($dom,'email'); + if (ref($emailrules) eq 'HASH') { + if (keys(%{$emailrules}) > 0) { + $datatable .= &user_formats_row('email',$settings,$emailrules, + $emailruleorder,$numinrow,$rownum); + $rownum ++; + $$rowtotal ++; + } + } + $datatable .= &captcha_choice('cancreate',$createsettings,$rownum); + } + return $datatable; +} + sub captcha_choice { my ($context,$settings,$itemcount) = @_; my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext); my %lt = &captcha_phrases(); $keyentry = 'hidden'; if ($context eq 'cancreate') { - $rowname = &mt('CAPTCHA validation (e-mail as username)'); + $rowname = &mt('CAPTCHA validation'); } elsif ($context eq 'login') { $rowname = &mt('"Contact helpdesk" CAPTCHA validation'); } @@ -3911,18 +3996,26 @@ sub usercreation_types { author => 'When adding a co-author', course => 'When adding a user to a course', requestcrs => 'When requesting a course', - selfcreate => 'User creates own account', any => 'Any', official => 'Institutional only ', unofficial => 'Non-institutional only', - email => 'E-mail address', - login => 'Institutional Login', - sso => 'SSO', none => 'None', ); return %lt; } +sub selfcreation_types { + my %lt = &Apache::lonlocal::texthash ( + selfcreate => 'User creates own account', + any => 'Any', + official => 'Institutional only ', + unofficial => 'Non-institutional only', + email => 'E-mail address', + login => 'Institutional Login', + sso => 'SSO', + ); +} + sub authtype_names { my %lt = &Apache::lonlocal::texthash( int => 'Internal', @@ -3964,20 +4057,6 @@ sub print_usermodification { $$rowtotal ++; $rowcount ++; } - } elsif ($position eq 'bottom') { - $context = 'selfcreate'; - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - $usertypes->{'default'} = $othertitle; - if (ref($types) eq 'ARRAY') { - push(@{$types},'default'); - $usertypes->{'default'} = $othertitle; - foreach my $status (@{$types}) { - $datatable .= &modifiable_userdata_row($context,$status,$settings, - $numinrow,$rowcount,$usertypes); - $$rowtotal ++; - $rowcount ++; - } - } } return $datatable; } @@ -4758,9 +4837,13 @@ sub build_category_rows { } sub modifiable_userdata_row { - my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_; + my ($context,$role,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref) = @_; my $rolename; - if ($context eq 'selfcreate') { + if ($context eq 'cancreate') { + if ($role eq 'emailusername') { + $rolename = &mt('Data user provides'); + } + } elsif ($context eq 'selfcreate') { if (ref($usertypes) eq 'HASH') { $rolename = $usertypes->{$role}; } else { @@ -4773,9 +4856,18 @@ sub modifiable_userdata_row { $rolename = &Apache::lonnet::plaintext($role); } } - my @fields = ('lastname','firstname','middlename','generation', - 'permanentemail','id'); - my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); + my (@fields,%fieldtitles); + if (ref($fieldsref) eq 'ARRAY') { + @fields = @{$fieldsref}; + } else { + @fields = ('lastname','firstname','middlename','generation', + 'permanentemail','id'); + } + if ((ref($titlesref) eq 'HASH')) { + %fieldtitles = %{$titlesref}; + } else { + %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); + } my $output; my $css_class = $rowcount%2?' class="LC_odd_row"':''; $output = ''. @@ -4831,7 +4923,7 @@ sub modifiable_userdata_row { } sub insttypes_row { - my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context) = @_; + my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rownum) = @_; my %lt = &Apache::lonlocal::texthash ( cansearch => 'Users allowed to search', statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)', @@ -4845,9 +4937,13 @@ sub insttypes_row { if ($context eq 'statustocreate') { $class = 'LC_right_item'; } - my $output = ''. - '
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
'.$text.''; my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - 'reqapprovalnotify',%currapp); + $action.'notifyapproval',%currapp); if ($numdc > 0) { $datatable .= $table; } else { @@ -3631,42 +3648,22 @@ sub print_usercreation { $rowcount ++; } } - my ($emailrules,$emailruleorder) = - &Apache::lonnet::inst_userrules($dom,'email'); - if (ref($emailrules) eq 'HASH') { - if (keys(%{$emailrules}) > 0) { - $datatable .= &user_formats_row('email',$settings,$emailrules, - $emailruleorder,$numinrow,$rowcount); - $$rowtotal ++; - $rowcount ++; - } - } if ($rowcount == 0) { $datatable .= '
'.&mt('No format rules have been defined for usernames or IDs in this domain.').'
'.$lt{$item}. ''; - my @options; - if ($item eq 'selfcreate') { - push(@options,('email','login','sso')); - } else { - @options = ('any'); - if (ref($rules) eq 'HASH') { - if (keys(%{$rules}) > 0) { - push(@options,('official','unofficial')); - } + my @options = ('any'); + if (ref($rules) eq 'HASH') { + if (keys(%{$rules}) > 0) { + push(@options,('official','unofficial')); } - push(@options,'none'); } + push(@options,'none'); foreach my $option (@options) { my $type = 'radio'; my $check = ' '; - if ($item eq 'selfcreate') { - $type = 'checkbox'; - if (grep(/^\Q$option\E$/,@selfcreate)) { - $check = ' checked="checked" '; - } - } else { - if ($checked{$item} eq $option) { - $check = ' checked="checked" '; - } + if ($checked{$item} eq $option) { + $check = ' checked="checked" '; } $datatable .= ''.&mt('E-mail address as username'). + ''. + ''; + foreach my $option ('email','emailapproval','off') { + my $checked; + if ($option eq 'email') { + if ($radiohash{'cancreate_email'}) { + $checked = 'checked="checked"'; + } + } elsif ($option eq 'emailapproval') { + if ($radiohash{'cancreate_emailapproval'}) { + $checked = 'checked="checked"'; + } + } else { + if ((!$radiohash{'cancreate_email'}) && (!$radiohash{'cancreate_emailapproval'})) { + $checked = 'checked="checked"'; + } + } + $datatable .= ' '; + } + $$rowtotal ++; + $rownum ++; + $datatable .= '
'.$lt{$context}.$showdom. - ''; + my $css_class = ' class="LC_odd_row"'; + if ($rownum ne '') { + $css_class = ($rownum%2? ' class="LC_odd_row"':''); + } + my $output = ''. + '
'.$lt{$context}.$showdom. + ''; my $rem; if (ref($types) eq 'ARRAY') { for (my $i=0; $i<@{$types}; $i++) { @@ -6101,7 +6197,7 @@ sub modify_quotas { } } if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify'); + my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval'); @approvalnotify = sort(@approvalnotify); $confhash{'notify'}{'approval'} = join(',',@approvalnotify); my @crstypes = ('official','unofficial','community','textbook'); @@ -6445,7 +6541,7 @@ sub modify_quotas { $resulttext .= ''; } if (ref($changes{'authorquota'}) eq 'HASH') { - $resulttext .= '
  • '.&mt('Authoring space default quotas').'
      '; + $resulttext .= '
    • '.&mt('Authoring Space default quotas').'
        '; foreach my $type (@{$types},'default') { if (defined($changes{'authorquota'}{$type})) { my $typetitle = $usertypes->{$type}; @@ -7328,106 +7424,38 @@ sub modify_contacts { sub modify_usercreation { my ($dom,%domconfig) = @_; - my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate); + my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate); my $warningmsg; if (ref($domconfig{'usercreation'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'usercreation'}})) { - $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 @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule'); - 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); - 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.'); + 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}; } - } 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'); + 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'); + foreach my $item(@contexts) { + $cancreate{$item} = $env{'form.can_createuser_'.$item}; } - &process_captcha('cancreate',\%changes,\%cancreate,\%curr_usercreation); if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { foreach my $item (@contexts) { - 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); - } + if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) { + push(@{$changes{'cancreate'}},$item); } } } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { @@ -7478,21 +7506,6 @@ 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; @@ -7523,39 +7536,394 @@ 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 => { - cancreate => \%cancreate, - username_rule => \@username_rule, - id_rule => \@id_rule, - email_rule => \@email_rule, - authtypes => \%authhash, - } - ); + usercreation => \%save_usercreate, + ); 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 .= '
          • '.$context_title{$type}.' - '.&mt('assignable authentication types: '); + foreach my $auth (@authtypes) { + if ($authhash{$type}{$auth}) { + push(@allowed,$authname{$auth}); + } + } + if (@allowed > 0) { + $chgtext .= join(', ',@allowed).'
          • '; + } else { + $chgtext .= &mt('none').''; + } + } + $chgtext .= '
          '; + $resulttext .= '
        • '.&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); +# +# 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')) { + $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'}} = (); 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 the username', + email => 'users who provide a valid e-mail address for use as username (automatic creation)', + emailapproval => 'users who provide a valid e-mail address for use as username (queued for Domain Coordinator review)', ); +# +# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts +# is permitted. +# + foreach my $item ('login','sso','email') { + if ($item eq 'email') { + if ($env{'form.cancreate_email'} eq 'email') { + push(@{$cancreate{'selfcreate'}},'email'); + } elsif ($env{'form.cancreate_email'} eq 'emailapproval') { + push(@{$cancreate{'selfcreate'}},'emailapproval'); + } + } 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'} 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'); + 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 +# + + 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 selef-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 ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + 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} > 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) { + 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 (!$cancreate{$item}{$curr}) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } + foreach my $field (keys(%{$cancreate{$item}})) { + 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 (keys(%userinfo) > 0) { + push(@{$changes{'cancreate'}},$item); + } + } + } +# +# 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{'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 = &usercreation_types(); + my %lt = &selfcreation_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('creation of a new user account is not permitted.'); + $chgtext .= &mt('Self creation of a new user account is not permitted.'); } else { - $chgtext .= &mt('creation of a new account is permitted for:').'
            '; + $chgtext .= &mt('Self-creation of a new account is permitted for:'). + '
              '; foreach my $case (@{$cancreate{$type}}) { $chgtext .= '
            • '.$selfcreatetypes{$case}.'
            • '; } @@ -7564,7 +7932,10 @@ sub modify_usercreation { 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."). + ''; } } } @@ -7575,11 +7946,13 @@ sub modify_usercreation { (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):'); @@ -7596,7 +7969,9 @@ sub modify_usercreation { } $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 { @@ -7608,21 +7983,21 @@ sub modify_usercreation { } } } elsif ($type eq 'captcha') { - if ($cancreate{$type} eq 'notused') { + if ($savecaptcha{$type} eq 'notused') { $chgtext .= &mt('No CAPTCHA validation in use for self-creation screen.'); } else { my %captchas = &captcha_phrases(); - if ($captchas{$cancreate{$type}}) { - $chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}."); + if ($captchas{$savecaptcha{$type}}) { + $chgtext .= &mt("Validation for self-creation screen set to $captchas{$savecaptcha{$type}}."); } else { $chgtext .= &mt('Validation for self-creation screen set to unknown type.'); } } } elsif ($type eq 'recaptchakeys') { my ($privkey,$pubkey); - if (ref($cancreate{$type}) eq 'HASH') { - $pubkey = $cancreate{$type}{'public'}; - $privkey = $cancreate{$type}{'private'}; + if (ref($savecaptcha{$type}) eq 'HASH') { + $pubkey = $savecaptcha{$type}{'public'}; + $privkey = $savecaptcha{$type}{'private'}; } $chgtext .= &mt('ReCAPTCHA keys changes').'
              '; if (!$pubkey) { @@ -7636,51 +8011,35 @@ sub modify_usercreation { $chgtext .= '
            • '.&mt('Private key set to [_1]',$pubkey).'
            • '; } $chgtext .= '
            '; - } 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.'); + } elsif ($type eq 'emailusername') { + if (ref($cancreate{'emailusername'}) eq 'HASH') { + 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') { + $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'}; + } + } } } - $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'}.'
            • '; + if ($chgtext) { + $resulttext .= '
            • '.$chgtext.'
            • '; } } - $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) = @@ -7693,37 +8052,48 @@ sub modify_usercreation { } $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.'). + '
        • '; } } - - 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 .= '
          • '.$context_title{$type}.' - '.&mt('assignable authentication types: '); - foreach my $auth (@authtypes) { - if ($authhash{$type}{$auth}) { - push(@allowed,$authname{$auth}); + if (ref($changes{'selfcreate'}) eq 'ARRAY') { + $resulttext .= '
          • '.&mt('When self-creating institutional account:').'
              '; + 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 (@allowed > 0) { - $chgtext .= join(', ',@allowed).''; + my @modifiable; + $resulttext .= '
            • '. + &mt('Self-creation of account by users with status: [_1]', + ''.$typename.''). + ' - '.&mt('modifiable fields (if institutional data blank): '); + foreach my $field (@fields) { + if ($save_usermodify{'selfcreate'}{$type}{$field}) { + push(@modifiable,''.$fieldtitles{$field}.''); + } + } + if (@modifiable > 0) { + $resulttext .= join(', ',@modifiable); } else { - $chgtext .= &mt('none').'
            • '; + $resulttext .= &mt('none'); } + $resulttext .= ''; } - $chgtext .= '
            '; - $resulttext .= '
          • '.&mt('Authentication types available for assignment to new users').'
            '.$chgtext; - $resulttext .= '
          • '; + $resulttext .= '
          '; } $resulttext .= '
        '; } else { - $resulttext = &mt('No changes made to user creation settings'); + $resulttext = &mt('No changes made to self-creation settings'); } } else { $resulttext = ''. @@ -7790,17 +8160,20 @@ sub process_captcha { sub modify_usermodification { my ($dom,%domconfig) = @_; - my ($resulttext,%curr_usermodification,%changes); + my ($resulttext,%curr_usermodification,%changes,%modifyhash); if (ref($domconfig{'usermodification'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'usermodification'}})) { - $curr_usermodification{$key} = $domconfig{'usermodification'}{$key}; + if ($key eq 'selfcreate') { + $modifyhash{$key} = $domconfig{'usermodification'}{$key}; + } else { + $curr_usermodification{$key} = $domconfig{'usermodification'}{$key}; + } } } - my @contexts = ('author','course','selfcreate'); + my @contexts = ('author','course'); my %context_title = ( author => 'In author context', course => 'In course context', - selfcreate => 'When self creating account', ); my @fields = ('lastname','firstname','middlename','generation', 'permanentemail','id'); @@ -7808,14 +8181,7 @@ sub modify_usermodification { author => ['ca','aa'], course => ['st','ep','ta','in','cr'], ); - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - if (ref($types) eq 'ARRAY') { - push(@{$types},'default'); - $usertypes->{'default'} = $othertitle; - } - $roles{'selfcreate'} = $types; my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); - my %modifyhash; foreach my $context (@contexts) { foreach my $role (@{$roles{$context}}) { my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role); @@ -7861,26 +8227,13 @@ sub modify_usermodification { if (ref($changes{$context}) eq 'ARRAY') { foreach my $role (@{$changes{$context}}) { my $rolename; - if ($context eq 'selfcreate') { - $rolename = $role; - if (ref($usertypes) eq 'HASH') { - if ($usertypes->{$role} ne '') { - $rolename = $usertypes->{$role}; - } - } + if ($role eq 'cr') { + $rolename = &mt('Custom'); } else { - if ($role eq 'cr') { - $rolename = &mt('Custom'); - } else { - $rolename = &Apache::lonnet::plaintext($role); - } + $rolename = &Apache::lonnet::plaintext($role); } my @modifiable; - if ($context eq 'selfcreate') { - $resulttext .= '
      • '.&mt('Self-creation of account by users with status: [_1]',$rolename).' - '.&mt('modifiable fields (if institutional data blank): '); - } else { - $resulttext .= '
      • '.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: '); - } + $resulttext .= '
      • '.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: '); foreach my $field (@fields) { if ($modifyhash{$context}{$role}{$field}) { push(@modifiable,$fieldtitles{$field});