';
+ $rownum ++;
+ }
+ $$rowtotal += $rownum;
+ return $datatable;
+}
+
+sub defaults_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ 'auth_def' => 'Default authentication type',
+ 'auth_arg_def' => 'Default authentication argument',
+ 'lang_def' => 'Default language',
+ );
+ return (\%titles);
+}
+
+
sub modifiable_userdata_row {
my ($context,$role,$settings,$numinrow,$rowcount) = @_;
my $rolename;
@@ -1908,12 +2000,13 @@ sub modify_login {
my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
my %title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
+ newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
my @offon = ('off','on');
my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- my @toggles = ('coursecatalog','adminmail');
+ my @toggles = ('coursecatalog','adminmail','newuser');
foreach my $item (@toggles) {
$loginhash{login}{$item} = $env{'form.'.$item};
}
@@ -1925,10 +2018,11 @@ sub modify_login {
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- my @toggles = ('coursecatalog','adminmail');
+ my @toggles = ('coursecatalog','adminmail','newuser');
my %defaultchecked = (
'coursecatalog' => 'on',
'adminmail' => 'off',
+ 'newuser' => 'off',
);
foreach my $item (@toggles) {
if ($defaultchecked{$item} eq 'on') {
@@ -3097,20 +3191,26 @@ sub modify_contacts {
sub modify_usercreation {
my ($dom,%domconfig) = @_;
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
+ my $warningmsg;
if (ref($domconfig{'usercreation'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'usercreation'}})) {
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
}
}
- my %title = &Apache::lonlocal::texthash (
- author => 'adding co-authors/assistant authors',
- course => 'adding users to a course',
- );
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');
+ my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
+ my @contexts = ('author','course','selfenroll');
foreach my $item(@contexts) {
$cancreate{$item} = $env{'form.can_createuser_'.$item};
+ if ($item eq 'selfenroll') {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
+ if (($cancreate{$item} eq 'any') || ($cancreate{$item} eq 'login')) {
+ $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 (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
@@ -3120,7 +3220,7 @@ sub modify_usercreation {
}
} elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
foreach my $item (@contexts) {
- if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
+ if (!grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
if ($cancreate{$item} ne 'any') {
push(@{$changes{'cancreate'}},$item);
}
@@ -3131,7 +3231,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item ('author','course') {
+ foreach my $item (@contexts) {
push(@{$changes{'cancreate'}},$item);
}
}
@@ -3166,10 +3266,25 @@ sub modify_usercreation {
push(@{$changes{'id_rule'}},@id_rule);
}
- my @contexts = ('author','course','domain');
+ 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;
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
foreach my $auth (@authtypes) {
if (grep(/^\Q$auth\E$/,@authallowed)) {
@@ -3180,7 +3295,7 @@ sub modify_usercreation {
}
}
if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
foreach my $auth (@authtypes) {
if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
@@ -3191,7 +3306,7 @@ sub modify_usercreation {
}
}
} else {
- foreach my $item (@contexts) {
+ foreach my $item (@authen_contexts) {
push(@{$changes{'authtypes'}},$item);
}
}
@@ -3201,6 +3316,7 @@ sub modify_usercreation {
cancreate => \%cancreate,
username_rule => \@username_rule,
id_rule => \@id_rule,
+ email_rule => \@email_rule,
authtypes => \%authhash,
}
);
@@ -3213,15 +3329,29 @@ sub modify_usercreation {
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext;
- if ($cancreate{$type} eq 'none') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.');
- } elsif ($cancreate{$type} eq 'any') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.');
- } elsif ($cancreate{$type} eq 'official') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for institutional usernames.',$lt{$type});
- } elsif ($cancreate{$type} eq 'unofficial') {
- $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for non-institutional usernames.',$lt{$type});
+ my $chgtext = $lt{$type}.', ';
+ if ($type eq 'selfenroll') {
+ if ($cancreate{$type} eq 'none') {
+ $chgtext .= &mt('creation of a new user account is not permitted.');
+ } elsif ($cancreate{$type} eq 'any') {
+ $chgtext .= &mt('creation of a new account is permitted for users authenticated by institutional log-in and SSO, and also for e-mail addresses used as usernames.');
+ } elsif ($cancreate{$type} eq 'login') {
+ $chgtext .= &mt('creation of a new account is only permitted for users authenticated by institutional log-in.');
+ } elsif ($cancreate{$type} eq 'sso') {
+ $chgtext .= &mt('creation of a new account is only permitted for users authenticated by institutional single sign on.');
+ } elsif ($cancreate{$type} eq 'email') {
+ $chgtext .= &mt('creation of a new account is only permitted for users who provide a valid e-mail address for use as the username.');
+ }
+ } 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.');
+ }
}
$resulttext .= '