'."\n";
@@ -5878,12 +5928,10 @@ sub print_selfcreation {
$$rowtotal ++;
my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
$numinrow = 1;
- if (ref($order) eq 'ARRAY') {
- foreach my $status (@{$order}) {
- $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
- $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles);
- $$rowtotal ++;
- }
+ foreach my $status (@ordered) {
+ $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
+ $numinrow,$$rowtotal,\%usertypeshash,$infofields,$infotitles);
+ $$rowtotal ++;
}
my ($emailrules,$emailruleorder) =
&Apache::lonnet::inst_userrules($dom,'email');
@@ -5899,15 +5947,20 @@ sub print_selfcreation {
return $datatable;
}
-sub email_as_username {
+sub validate_by_email {
my ($rowtotal,$processing,$type) = @_;
my %choices =
&Apache::lonlocal::texthash (
automatic => 'Automatic approval',
approval => 'Queued for approval',
+ notinuse => 'Unavailable',
);
my $output;
- foreach my $option ('automatic','approval') {
+ my @options = ('automatic','approval');
+ unless ($type eq '') {
+ push(@options,'notinuse');
+ }
+ foreach my $option (@options) {
my $checked;
if (ref($processing) eq 'HASH') {
if ($type eq '') {
@@ -5952,6 +6005,83 @@ sub email_as_username {
return $output;
}
+sub email_as_username {
+ my ($rowtotal,$emailverified,$emaildomain,$type) = @_;
+ my %choices =
+ &Apache::lonlocal::texthash (
+ email => 'Username is e-mail',
+ other => 'Username is chosen',
+ );
+ my $name = 'cancreate_emailverified';
+ my $condition = 'cancreate_emaildomain';
+ if (($type ne '') && ($type ne 'default')) {
+ $name .= '_'.$type;
+ $condition .= '_'.$type;
+ }
+ my $display = 'none';
+ my $onclick = "toggleDisplay(this.form,'$name');";
+
+ my $output;
+ foreach my $option ('email','other') {
+ my ($checked,$domain);
+ if (ref($emailverified) eq 'HASH') {
+ if ($type eq '') {
+ if (!exists($emailverified->{'default'})) {
+ if ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($emailverified->{'default'} eq $option) {
+ $checked = ' checked="checked"';
+ }
+ }
+ } else {
+ if (!exists($emailverified->{$type})) {
+ if ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($emailverified->{$type} eq $option) {
+ $checked = ' checked="checked"';
+ if ($option eq 'other') {
+ $display = 'inline';
+ }
+ }
+ }
+ }
+ } elsif ($option eq 'email') {
+ $checked = ' checked="checked"';
+ }
+ $output .= '';
+ if ($type eq '') {
+ $output .= ' ';
+ } else {
+ $output .= ' ';
+ }
+ }
+ my $domain;
+ if (ref($emaildomain) eq 'HASH') {
+ if ($type eq '') {
+ if (exists($emaildomain->{'default'})) {
+ $domain = $emaildomain->{'default'};
+ }
+ } else {
+ if (exists($emaildomain->{$type})) {
+ $domain = $emaildomain->{$type};
+ }
+ }
+ }
+ $output .= '
'.
+ ''.&mt('E-mail domain').' '.
+ ''.
+ '
';
+ $$rowtotal ++;
+ return $output;
+}
+
sub captcha_choice {
my ($context,$settings,$itemcount) = @_;
my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
@@ -9466,7 +9596,7 @@ sub process_textbook_image {
sub modify_ltitools {
my ($r,$dom,$action,$lastactref,%domconfig) = @_;
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- my ($newid,@allpos,%changes,%confhash,$errors,$resulttext);
+ my ($newid,@allpos,%changes,%confhash,%encconfig,$errors,$resulttext);
my $confname = $dom.'-domainconfig';
my $servadm = $r->dir_config('lonAdmEMail');
my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
@@ -9491,7 +9621,11 @@ sub modify_ltitools {
foreach my $item ('title','url','key','secret') {
$env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
if ($env{'form.ltitools_add_'.$item}) {
- $confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item};
+ if (($item eq 'key') || ($item eq 'secret')) {
+ $encconfig{$newid}{$item} = $env{'form.ltitools_add_'.$item};
+ } else {
+ $confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item};
+ }
}
}
if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
@@ -9515,6 +9649,8 @@ sub modify_ltitools {
}
if ($env{'form.ltitools_add_target'} eq 'window') {
$confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
+ } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
+ $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
} else {
$confhash{$newid}{'display'}{'target'} = 'iframe';
}
@@ -9598,12 +9734,18 @@ sub modify_ltitools {
} else {
my $newpos = $env{'form.ltitools_'.$itemid};
$newpos =~ s/\D+//g;
- foreach my $item ('title','url','key','secret') {
+ foreach my $item ('title','url') {
$confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
$changes{$itemid} = 1;
}
}
+ foreach my $item ('key','secret') {
+ $encconfig{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
+ if ($domconfig{$action}{$itemid}{$item} ne $encconfig{$itemid}{$item}) {
+ $changes{$itemid} = 1;
+ }
+ }
if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
$confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
}
@@ -9648,6 +9790,8 @@ sub modify_ltitools {
}
if ($env{'form.ltitools_target_'.$i} eq 'window') {
$confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
+ } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
+ $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
} else {
$confhash{$itemid}{'display'}{'target'} = 'iframe';
}
@@ -9806,9 +9950,21 @@ sub modify_ltitools {
my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,
$dom);
if ($putresult eq 'ok') {
+ my %ltienchash = (
+ $action => { %encconfig }
+ );
+ &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
- &Apache::lonnet::do_cache_new('ltitools',$dom,\%confhash,$cachetime);
+ my %ltiall = %confhash;
+ foreach my $id (keys(%ltiall)) {
+ if (ref($encconfig{$id}) eq 'HASH') {
+ foreach my $item ('key','secret') {
+ $ltiall{$id}{$item} = $encconfig{$id}{$item};
+ }
+ }
+ }
+ &Apache::lonnet::do_cache_new('ltitools',$dom,\%ltiall,$cachetime);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'ltitools'} = 1;
}
@@ -9832,14 +9988,17 @@ sub modify_ltitools {
$resulttext .= '
';
my $position = $pos + 1;
$resulttext .= '
'.&mt('Order: [_1]',$position).'
';
- foreach my $item ('version','msgtype','url','key') {
+ foreach my $item ('version','msgtype','url') {
if ($confhash{$itemid}{$item} ne '') {
$resulttext .= '
'.$lt{$item}.': '.$confhash{$itemid}{$item}.'
';
}
}
- if ($confhash{$itemid}{'secret'} ne '') {
+ if ($encconfig{$itemid}{'key'} ne '') {
+ $resulttext .= '
'.$lt{'key'}.': '.$encconfig{$itemid}{'key'}.'
';
+ }
+ if ($encconfig{$itemid}{'secret'} ne '') {
$resulttext .= '
'.$lt{'secret'}.': ';
- my $num = length($confhash{$itemid}{'secret'});
+ my $num = length($encconfig{$itemid}{'secret'});
$resulttext .= ('*'x$num).'
';
}
$resulttext .= '
'.&mt('Configurable in course:');
@@ -10102,9 +10261,9 @@ sub modify_autoenroll {
}
if ($changes{'autofailsafe'}) {
if ($failsafe ne '') {
- $resulttext .= '
'.&mt("$title{'failsafe'} set to [_1]",$failsafe).'
';
+ $resulttext .= '
'.&mt('Failsafe for no drops if institutional data missing for a section set to: [_1]',$failsafe).'
';
- }
+ }
} elsif ($type eq 'statustocreate') {
if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
(ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
@@ -11539,7 +11736,7 @@ sub modify_selfcreation {
&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").
'
';
}
- } elsif (ref($usertypes) eq 'HASH') {
+ } elsif (keys(%usertypes) > 0) {
if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
$chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
} else {
@@ -11550,12 +11747,12 @@ sub modify_selfcreation {
if ($case eq 'default') {
$chgtext .= '
'.$othertitle.'
';
} else {
- $chgtext .= '
'.$usertypes->{$case}.'
';
+ $chgtext .= '
'.$usertypes{$case}.'
';
}
}
$chgtext .= '';
if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
- $chgtext .= ' '.
+ $chgtext .= ''.
&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').
'';
}
@@ -11567,26 +11764,109 @@ sub modify_selfcreation {
$chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
}
}
+ $chgtext .= ' ';
}
} elsif ($type eq 'selfcreateprocessing') {
my %choices = &Apache::lonlocal::texthash (
automatic => 'Automatic approval',
approval => 'Queued for approval',
+ notinuse => 'Unavailable',
);
if (@statuses > 1) {
- $chgtext .= &mt('Processing of requests to create account with e-mail address as username set as follows:').
- '
';
- foreach my $type (@statuses) {
- if ($type eq 'default') {
- $chgtext .= '
';
+ }
+ } else {
+ if ($cancreate{'emailverified'}{'default'} eq 'other') {
+ if ($cancreate{'emaildomain'}{'default'} eq '') {
+ $chgtext .= &mt('No restriction on e-mail domain for self-created accounts verified by e-mail address, where username is chosen by user.');
+ } else {
+ $chgtext .= &mt('For self-created accounts verified by e-mail address, where username is chosen by user, e-mail domain needs to be: [_1]',
+ $cancreate{'selfcreateprocessing'}{'default'});
+ }
+ }
}
} elsif ($type eq 'captcha') {
if ($savecaptcha{$type} eq 'notused') {
@@ -11623,11 +11903,11 @@ sub modify_selfcreation {
}
} elsif ($type eq 'emailusername') {
if (ref($cancreate{'emailusername'}) eq 'HASH') {
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
+ if (@types) {
+ foreach my $type (@types) {
if (ref($cancreate{'emailusername'}{$type}) eq 'HASH') {
if (keys(%{$cancreate{'emailusername'}{$type}}) > 0) {
- $chgtext .= &mt('When self-creating account with e-mail as username, the following information will be provided by [_1]:',"'$usertypes->{$type}'").
+ $chgtext .= &mt('When self-creating account with e-mail verification, the following information will be provided by [_1]:',"'$usertypes{$type}'").
'
';
foreach my $field (@{$infofields}) {
if ($cancreate{'emailusername'}{$type}{$field}) {
@@ -11636,23 +11916,27 @@ sub modify_selfcreation {
}
$chgtext .= '
';
} else {
- $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',"'$usertypes->{$type}'").' ';
+ $chgtext .= &mt('When self creating account with e-mail verification, no information besides e-mail address will be provided by [_1].',"'$usertypes{$type}'").' ';
}
} else {
- $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',"'$usertypes->{$type}'").' ';
+ $chgtext .= &mt('When self creating account with e-mail verification, no information besides e-mail address will be provided by [_1].',"'$usertypes{$type}'").' ';
}
}
}
}
} elsif ($type eq 'notify') {
- $chgtext = &mt('No Domain Coordinators will receive notification of username requests requiring approval.');
+ my $numapprove = 0;
if (ref($changes{'cancreate'}) eq 'ARRAY') {
if ((grep(/^notify$/,@{$changes{'cancreate'}})) && (ref($cancreate{'notify'}) eq 'HASH')) {
if ($cancreate{'notify'}{'approval'}) {
- $chgtext = &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'};
+ $chgtext .= &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'};
+ $numapprove ++;
}
}
}
+ unless ($numapprove) {
+ $chgtext .= &mt('No Domain Coordinators will receive notification of username requests requiring approval.');
+ }
}
if ($chgtext) {
$resulttext .= '
'.$chgtext.'
';
@@ -11671,12 +11955,12 @@ sub modify_selfcreation {
$chgtext .= '';
if (@email_rule > 0) {
$resulttext .= '
'.
- &mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').
+ &mt('Accounts may not be created by users verified by e-mail, for e-mail addresses of the following types: ').
$chgtext.
'
';
} else {
$resulttext .= '
'.
- &mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').
+ &mt('There are now no restrictions on e-mail addresses which may be used for verification when self-enrolling.').
'
';
}
}
@@ -11685,9 +11969,9 @@ sub modify_selfcreation {
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
foreach my $type (@{$changes{'selfcreate'}}) {
my $typename = $type;
- if (ref($usertypes) eq 'HASH') {
- if ($usertypes->{$type} ne '') {
- $typename = $usertypes->{$type};
+ if (keys(%usertypes) > 0) {
+ if ($usertypes{$type} ne '') {
+ $typename = $usertypes{$type};
}
}
my @modifiable;
@@ -12933,7 +13217,7 @@ sub modify_helpsettings {
order => 'Order',
desc => 'Role description',
access => 'Role usage',
- status => 'Allowed instituional types',
+ status => 'Allowed institutional types',
exc => 'Allowed personnel',
inc => 'Disallowed personnel',
);
@@ -15188,6 +15472,7 @@ function toggleDisplay(domForm,caller) {
var optionsElement = domForm.coursecredits;
var checkval = 1;
var dispval = 'block';
+ var selfcreateRegExp = /^cancreate_emailverified/;
if (caller == 'emailoptions') {
optionsElement = domForm.cancreate_email;
}
@@ -15198,6 +15483,11 @@ function toggleDisplay(domForm,caller) {
optionsElement = domForm.canclone;
checkval = 'instcode';
}
+ if (selfcreateRegExp.test(caller)) {
+ optionsElement = domForm.elements[caller];
+ checkval = 'other';
+ dispval = 'inline'
+ }
if (optionsElement.length) {
var currval;
for (var i=0; i