[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm

raeburn raeburn at source.lon-capa.org
Sat Feb 15 12:07:20 EST 2014


raeburn		Sat Feb 15 17:07:20 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport 1.223, 1.224, 1.225.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.33 loncom/interface/domainprefs.pm:1.160.6.34
--- loncom/interface/domainprefs.pm:1.160.6.33	Mon Jan  6 14:08:31 2014
+++ loncom/interface/domainprefs.pm	Sat Feb 15 17:07:19 2014
@@ -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 @@
 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 @@
                 '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 @@
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
                   },
-
         'usercreation' => 
                   { text => 'User creation',
                     help => 'Domain_Configuration_User_Creation',
@@ -304,15 +303,23 @@
                                {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 @@
                               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 @@
         $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 @@
             $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 @@
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>             </tr>'.
             &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).'
            </table>
           </td>
          </tr>
@@ -659,9 +670,12 @@
             <table class="LC_nested">
              <tr class="LC_info_row">
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
-              <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td></tr>'.
-                       &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+              <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
+             </tr>'.
+            &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 @@
     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 = '<tr '.$css_class.'>'.
+    $datatable = '<tr'.$css_class.'>'.
                  ' <td>'.$text.'</td>'.
                  ' <td class="LC_left_item">';
     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 @@
                 $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 .= '<tr><td colspan="2">'.&mt('No format rules have been defined for usernames or IDs in this domain.').'</td></tr>';  
             $$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 @@
         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 @@
             $datatable .= '<tr'.$css_class.'>'.
                          '<td><span class="LC_nobreak">'.$lt{$item}.
                          '</span></td><td align="right">';
-            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$/, at selfcreate)) {
-                        $check = ' checked="checked" ';
-                    }
-                } else {
-                    if ($checked{$item} eq $option) {
-                        $check = ' checked="checked" ';
-                    }
+                if ($checked{$item} eq $option) {
+                    $check = ' checked="checked" ';
                 } 
                 $datatable .= '<span class="LC_nobreak"><label>'.
                               '<input type="'.$type.'" name="can_createuser_'.
@@ -3724,22 +3707,6 @@
             }
             $datatable .= '</td></tr>';
         }
-        my ($othertitle,$usertypes,$types) =
-            &Apache::loncommon::sorted_inst_types($dom);
-        my $createsettings;
-        if (ref($settings) eq 'HASH') {
-            $createsettings = $settings->{cancreate};
-        }
-        if (ref($usertypes) eq 'HASH') {
-            if (keys(%{$usertypes}) > 0) {
-                $datatable .= &insttypes_row($createsettings,$types,$usertypes,
-                                             $dom,$numinrow,$othertitle,
-                                             'statustocreate');
-                $$rowtotal ++;
-                $rownum ++;
-            }
-        }
-        $datatable .= &captcha_choice('cancreate',$createsettings,$rownum);
     } else {
         my @contexts = ('author','course','domain');
         my @authtypes = ('int','krb4','krb5','loc');
@@ -3791,13 +3758,131 @@
     return $datatable;
 }
 
+sub print_selfcreation {
+    my ($position,$dom,$settings,$rowtotal) = @_;
+    my (@selfcreate,$createsettings,$datatable);
+    if (ref($settings) eq 'HASH') {
+        if (ref($settings->{'cancreate'}) eq 'HASH') {
+            $createsettings = $settings->{'cancreate'};
+            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'});
+                }
+            }
+        }
+    }
+    my %radiohash;
+    my $rownum = 0;
+    my $numinrow = 4;
+    map { $radiohash{'cancreate_'.$_} = 1; } @selfcreate;
+    if ($position eq 'top') {
+        my %choices = &Apache::lonlocal::texthash (
+                                                      cancreate_login      => 'Institutional Login',
+                                                      cancreate_sso        => 'Institutional Single Sign On',
+                                                  );
+        my @toggles = sort(keys(%choices));
+        my %defaultchecked = (
+                               'cancreate_login' => 'off',
+                               'cancreate_sso'   => 'off',
+                             );
+        my $itemcount = 1;
+        my $onclick;
+        ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
+                                                     \%choices,$itemcount,$onclick);
+        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,
+                                             $dom,$numinrow,$othertitle,
+                                             'statustocreate',$rownum);
+                $rownum ++;
+                $$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;
+        if (ref($types) eq 'ARRAY') {
+            push(@{$types},'default');
+            $usertypes->{'default'} = $othertitle;
+            foreach my $status (@{$types}) {
+                $rownum ++;
+                $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
+                                                       $numinrow,$rownum,$usertypes);
+                $$rowtotal ++;
+            }
+        }
+    } else {
+        my $css_class = $rownum%2?' class="LC_odd_row"':'';
+        my %choices =
+            &Apache::lonlocal::texthash(
+                                          email         => 'Approved automatically',
+                                          emailapproval => 'Queued for approval by DC',
+                                          off           => 'Not enabled',
+                                       );
+        $datatable .= '<tr'.$css_class.'>'.
+                      '<td>'.&mt('E-mail address as username').
+                      '</td><td class="LC_left_item">'.
+                      '<span class="LC_nobreak">';
+        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 .= '<label>'.
+                          '<input type="radio" name="cancreate_email" '.
+                          $checked.' value="'.$option.'" />'.
+                          $choices{$option}.'</label> ';
+        }
+        $$rowtotal ++;
+        $rownum ++;
+        $datatable .= '</span></td></tr>'.
+                      &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 @@
                     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 @@
             $$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 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 @@
             $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 = '<tr '.$css_class.'>'.
@@ -4831,7 +4923,7 @@
 }
 
 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 @@
     if ($context eq 'statustocreate') {
         $class = 'LC_right_item';
     }
-    my $output =  '<tr class="LC_odd_row">'.
-                  '<td>'.$lt{$context}.$showdom.
-                  '</td><td class="'.$class.'" colspan="2"><table>';
+    my $css_class = ' class="LC_odd_row"';
+    if ($rownum ne '') { 
+        $css_class = ($rownum%2? ' class="LC_odd_row"':'');
+    }
+    my $output = '<tr'.$css_class.'>'.
+                 '<td>'.$lt{$context}.$showdom.
+                 '</td><td class="'.$class.'" colspan="2"><table>';
     my $rem;
     if (ref($types) eq 'ARRAY') {
         for (my $i=0; $i<@{$types}; $i++) {
@@ -6101,7 +6197,7 @@
         }
     }
     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(',', at approvalnotify);
         my @crstypes = ('official','unofficial','community','textbook');
@@ -6445,7 +6541,7 @@
                     $resulttext .= '</ul></li>';
                 }
                 if (ref($changes{'authorquota'}) eq 'HASH') {
-                    $resulttext .= '<li>'.&mt('Authoring space default quotas').'<ul>';
+                    $resulttext .= '<li>'.&mt('Authoring Space default quotas').'<ul>';
                     foreach my $type (@{$types},'default') {
                         if (defined($changes{'authorquota'}{$type})) {
                             my $typetitle = $usertypes->{$type};
@@ -7328,106 +7424,38 @@
 
 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 @@
         push(@{$changes{'id_rule'}}, at id_rule);
     }
 
-    if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
-        foreach my $type (@{$curr_usercreation{'email_rule'}}) {
-            if (!grep(/^\Q$type\E$/, at 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'}}, at email_rule);
-    }
-
     my @authen_contexts = ('author','course','domain');
     my @authtypes = ('int','krb4','krb5','loc');
     my %authhash;
@@ -7523,39 +7536,394 @@
         }
     }
 
+    $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:').'<ul>';
+            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 .= '<li>'.$chgtext.'</li>';
+                }
+            }
+            if (ref($changes{'username_rule'}) eq 'ARRAY') {
+                my ($rules,$ruleorder) = 
+                    &Apache::lonnet::inst_userrules($dom,'username');
+                my $chgtext = '<ul>';
+                foreach my $type (@username_rule) {
+                    if (ref($rules->{$type}) eq 'HASH') {
+                        $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
+                    }
+                }
+                $chgtext .= '</ul>';
+                if (@username_rule > 0) {
+                    $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';     
+                } else {
+                    $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>'; 
+                }
+            }
+            if (ref($changes{'id_rule'}) eq 'ARRAY') {
+                my ($idrules,$idruleorder) = 
+                    &Apache::lonnet::inst_userrules($dom,'id');
+                my $chgtext = '<ul>';
+                foreach my $type (@id_rule) {
+                    if (ref($idrules->{$type}) eq 'HASH') {
+                        $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
+                    }
+                }
+                $chgtext .= '</ul>';
+                if (@id_rule > 0) {
+                    $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
+                } else {
+                    $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
+                }
+            }
+            my %authname = &authtype_names();
+            my %context_title = &context_names();
+            if (ref($changes{'authtypes'}) eq 'ARRAY') {
+                my $chgtext = '<ul>';
+                foreach my $type (@{$changes{'authtypes'}}) {
+                    my @allowed;
+                    $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
+                    foreach my $auth (@authtypes) {
+                        if ($authhash{$type}{$auth}) {
+                            push(@allowed,$authname{$auth});
+                        }
+                    }
+                    if (@allowed > 0) {
+                        $chgtext .= join(', ', at allowed).'</li>';
+                    } else {
+                        $chgtext .= &mt('none').'</li>';
+                    }
+                }
+                $chgtext .= '</ul>';
+                $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
+                $resulttext .= '</li>';
+            }
+            $resulttext .= '</ul>';
+        } else {
+            $resulttext = &mt('No changes made to user creation settings');
+        }
+    } else {
+        $resulttext = '<span class="LC_error">'.
+            &mt('An error occurred: [_1]',$putresult).'</span>';
+    }
+    if ($warningmsg ne '') {
+        $resulttext .= '<br /><span class="LC_warning">'.$warningmsg.'</span><br />';
+    }
+    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(',', at 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$/, at 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'}}, at 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$/, at 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:').'<ul>';
             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:').'<ul>';
+                            $chgtext .= &mt('Self-creation of a new account is permitted for:').
+                                        '<ul>';
                             foreach my $case (@{$cancreate{$type}}) {
                                 $chgtext .= '<li>'.$selfcreatetypes{$case}.'</li>';
                             }
@@ -7564,7 +7932,10 @@
                                 if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
                                     if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
                                         if (@{$cancreate{'statustocreate'}} == 0) {
-                                            $chgtext .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
+                                            $chgtext .= '<br />'.
+                                                        '<span class="LC_warning">'.
+                                                        &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").
+                                                        '</span>';
                                         }
                                     }
                                 }
@@ -7575,11 +7946,13 @@
                             (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 .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
-                                    } 
+                                        $chgtext .= '<br />'.
+                                                    '<span class="LC_warning">'.
+                                                    &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").
+                                                    '</span>';
+                                    }
                                 } 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 @@
                                     }
                                     $chgtext .= '</ul>';
                                     if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
-                                        $chgtext .= '<br /><span class="LC_warning">'.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'</span>';
+                                        $chgtext .= '<br /><span class="LC_warning">'.
+                                                    &mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').
+                                                    '</span>';
                                     }
                                 }
                             } else {
@@ -7608,21 +7983,21 @@
                             }
                         }
                     } 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').'<ul>';
                         if (!$pubkey) {
@@ -7636,51 +8011,35 @@
                             $chgtext .= '<li>'.&mt('Private key set to [_1]',$pubkey).'</li>';
                         }
                         $chgtext .= '</ul>';
-                    } 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:').
+                                            '<ul>';
+                                foreach my $field (@{$infofields}) {
+                                    if ($cancreate{'emailusername'}{$field}) {
+                                        $chgtext .= '<li>'.$infotitles->{$field}.'</li>';
+                                    }
+                                }
+                                $chgtext .= '</ul>';
+                            } 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 .= '<li>'.$chgtext.'</li>';
-                }
-            }
-            if (ref($changes{'username_rule'}) eq 'ARRAY') {
-                my ($rules,$ruleorder) = 
-                    &Apache::lonnet::inst_userrules($dom,'username');
-                my $chgtext = '<ul>';
-                foreach my $type (@username_rule) {
-                    if (ref($rules->{$type}) eq 'HASH') {
-                        $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
-                    }
-                }
-                $chgtext .= '</ul>';
-                if (@username_rule > 0) {
-                    $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';     
-                } else {
-                    $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>'; 
-                }
-            }
-            if (ref($changes{'id_rule'}) eq 'ARRAY') {
-                my ($idrules,$idruleorder) = 
-                    &Apache::lonnet::inst_userrules($dom,'id');
-                my $chgtext = '<ul>';
-                foreach my $type (@id_rule) {
-                    if (ref($idrules->{$type}) eq 'HASH') {
-                        $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
+                    if ($chgtext) {
+                        $resulttext .= '<li>'.$chgtext.'</li>';
                     }
                 }
-                $chgtext .= '</ul>';
-                if (@id_rule > 0) {
-                    $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
-                } else {
-                    $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
-                }
             }
             if (ref($changes{'email_rule'}) eq 'ARRAY') {
                 my ($emailrules,$emailruleorder) =
@@ -7693,37 +8052,48 @@
                 }
                 $chgtext .= '</ul>';
                 if (@email_rule > 0) {
-                    $resulttext .= '<li>'.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'</li>';
+                    $resulttext .= '<li>'.
+                                   &mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').
+                                       $chgtext.
+                                   '</li>';
                 } else {
-                    $resulttext .= '<li>'.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'</li>';
+                    $resulttext .= '<li>'.
+                                   &mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').
+                                   '</li>';
                 }
             }
-
-            my %authname = &authtype_names();
-            my %context_title = &context_names();
-            if (ref($changes{'authtypes'}) eq 'ARRAY') {
-                my $chgtext = '<ul>';
-                foreach my $type (@{$changes{'authtypes'}}) {
-                    my @allowed;
-                    $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
-                    foreach my $auth (@authtypes) {
-                        if ($authhash{$type}{$auth}) {
-                            push(@allowed,$authname{$auth});
+            if (ref($changes{'selfcreate'}) eq 'ARRAY') {
+                $resulttext .= '<li>'.&mt('When self-creating institutional account:').'<ul>';
+                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(', ', at allowed).'</li>';
+                    my @modifiable;
+                    $resulttext .= '<li>'.
+                                    &mt('Self-creation of account by users with status: [_1]',
+                                        '<span class="LC_cusr_emph">'.$typename.'</span>').
+                                    ' - '.&mt('modifiable fields (if institutional data blank): ');
+                    foreach my $field (@fields) {
+                        if ($save_usermodify{'selfcreate'}{$type}{$field}) {
+                            push(@modifiable,'<b>'.$fieldtitles{$field}.'</b>');
+                        }
+                    }
+                    if (@modifiable > 0) {
+                        $resulttext .= join(', ', at modifiable);
                     } else {
-                        $chgtext .= &mt('none').'</li>';
+                        $resulttext .= &mt('none');
                     }
+                    $resulttext .= '</li>';
                 }
-                $chgtext .= '</ul>';
-                $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
-                $resulttext .= '</li>';
+                $resulttext .= '</ul></li>';
             }
             $resulttext .= '</ul>';
         } else {
-            $resulttext = &mt('No changes made to user creation settings');
+            $resulttext = &mt('No changes made to self-creation settings');
         }
     } else {
         $resulttext = '<span class="LC_error">'.
@@ -7790,17 +8160,20 @@
 
 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 @@
                   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 @@
                     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 .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1]',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');
-                            } else {
-                                $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
-                            }
+                            $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
                             foreach my $field (@fields) {
                                 if ($modifyhash{$context}{$role}{$field}) {
                                     push(@modifiable,$fieldtitles{$field});


More information about the LON-CAPA-cvs mailing list