--- loncom/interface/domainprefs.pm 2016/08/04 17:53:12 1.160.6.66
+++ loncom/interface/domainprefs.pm 2016/08/12 19:49:56 1.160.6.69
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.66 2016/08/04 17:53:12 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.69 2016/08/12 19:49:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2398,7 +2398,7 @@ ENDSCRIPT
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff,$coownerson,$coownersoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -2432,6 +2432,9 @@ sub print_autoenroll {
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ if (exists($settings->{'autofailsafe'})) {
+ $failsafe = $settings->{'autofailsafe'};
+ }
} else {
if ($autorun) {
$runon = ' checked="checked" ';
@@ -2467,8 +2470,12 @@ sub print_autoenroll {
$coownerson.' value="1" />'.&mt('Yes').' '.
''.
- '';
- $$rowtotal += 3;
+ '
'.
+ ''.&mt('Failsafe for no drops when institutional data missing').' | '.
+ ''.
+ ' |
';
+ $$rowtotal += 4;
return $datatable;
}
@@ -4535,7 +4542,8 @@ sub email_as_username {
sub captcha_choice {
my ($context,$settings,$itemcount) = @_;
- my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
+ my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
+ $vertext,$currver);
my %lt = &captcha_phrases();
$keyentry = 'hidden';
if ($context eq 'cancreate') {
@@ -4553,6 +4561,11 @@ sub captcha_choice {
$pubtext = $lt{'pub'};
$privtext = $lt{'priv'};
$keyentry = 'text';
+ $vertext = $lt{'ver'};
+ $currver = $settings->{'recaptchaversion'};
+ if ($currver ne '2') {
+ $currver = 1;
+ }
}
if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
$currpub = $settings->{'recaptchakeys'}{'public'};
@@ -4586,7 +4599,11 @@ sub captcha_choice {
$currpub.'" size="40" />
'."\n".
''.$privtext.' '."\n".
''."\n".
+ $currpriv.'" size="40" />
'.
+ ''.$vertext.' '."\n".
+ '
'.
+ ''."\n".
'';
return $output;
}
@@ -6147,7 +6164,7 @@ sub modify_login {
if ($domservers{$lonhost}) {
if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') {
$currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'};
- $currexempt{$lonhost} = $domconfig{'login'}{'headtagexempt'}{$lonhost}{'exempt'}
+ $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'}
}
}
}
@@ -6373,6 +6390,13 @@ sub modify_login {
$chgtxt .= '';
$resulttext .= ''.$chgtxt.'';
}
+ } elsif ($item eq 'recaptchaversion') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ if ($loginhash{'login'}{'captcha'} eq 'recaptcha') {
+ $resulttext .= ''.&mt('ReCAPTCHA for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+ '';
+ }
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
}
@@ -7885,7 +7909,8 @@ sub modify_autoenroll {
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my %title = ( run => 'Auto-enrollment active',
sender => 'Sender for notification messages',
- coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
+ coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)',
+ failsafe => 'Failsafe for no drops if institutional data missing for a section');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -7895,11 +7920,17 @@ sub modify_autoenroll {
$sender_domain = '';
}
my $coowners = $env{'form.autoassign_coowners'};
+ my $failsafe = $env{'form.autoenroll_failsafe'};
+ $failsafe =~ s{^\s+|\s+$}{}g;
+ if ($failsafe =~ /\D/) {
+ undef($failsafe);
+ }
my %autoenrollhash = (
autoenroll => { 'run' => $env{'form.autoenroll_run'},
'sender_uname' => $sender_uname,
'sender_domain' => $sender_domain,
'co-owners' => $coowners,
+ 'autofailsafe' => $failsafe,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -7926,7 +7957,10 @@ sub modify_autoenroll {
}
} elsif ($coowners) {
$changes{'coowners'} = 1;
- }
+ }
+ if ($currautoenroll{'autofailsafe'} ne $failsafe) {
+ $changes{'autofailsafe'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'run'}) {
@@ -7946,6 +7980,17 @@ sub modify_autoenroll {
$lastactref->{'domainconfig'} = 1;
}
}
+ if ($changes{'autofailsafe'}) {
+ if ($failsafe ne '') {
+ $resulttext .= '- '.&mt("$title{'failsafe'} set to [_1]",$failsafe).'
';
+ } else {
+ $resulttext .= '- '.&mt("$title{'failsafe'} deleted");
+ }
+ &Apache::lonnet::get_domain_defaults($dom,1);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
$resulttext .= '
';
} else {
$resulttext = &mt('No changes made to auto-enrollment settings');
@@ -8573,7 +8618,8 @@ sub modify_usercreation {
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 'captcha') || ($item eq 'recaptchakeys') ||
+ ($item eq 'recaptchaversion')) {
$save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
} else {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -8797,6 +8843,7 @@ sub modify_selfcreation {
foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
($item eq 'captcha') || ($item eq 'recaptchakeys') ||
+ ($item eq 'recaptchaversion') ||
($item eq 'emailusername') || ($item eq 'notify') ||
($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -9126,6 +9173,7 @@ sub modify_selfcreation {
#
$save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'};
$save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'};
+ $save_usercreate{'cancreate'}{'recaptchaversion'} = $savecaptcha{'recaptchaversion'};
$save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'};
if (ref($cancreate{'notify'}) eq 'HASH') {
$save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'};
@@ -9287,6 +9335,10 @@ sub modify_selfcreation {
$chgtext .= ''.&mt('Private key set to [_1]',$pubkey).'';
}
$chgtext .= '';
+ } elsif ($type eq 'recaptchaversion') {
+ if ($savecaptcha{'captcha'} eq 'recaptcha') {
+ $chgtext .= &mt('ReCAPTCHA set to version [_1]',$savecaptcha{$type});
+ }
} elsif ($type eq 'emailusername') {
if (ref($cancreate{'emailusername'}) eq 'HASH') {
if (ref($types) eq 'ARRAY') {
@@ -9407,7 +9459,7 @@ sub process_captcha {
$changes->{'captcha'} = 1;
}
}
- my ($newpub,$newpriv,$currpub,$currpriv);
+ my ($newpub,$newpriv,$currpub,$currpriv,$newversion,$currversion);
if ($newsettings->{'captcha'} eq 'recaptcha') {
$newpub = $env{'form.'.$container.'_recaptchapub'};
$newpriv = $env{'form.'.$container.'_recaptchapriv'};
@@ -9417,6 +9469,12 @@ sub process_captcha {
public => $newpub,
private => $newpriv,
};
+ $newversion = $env{'form.'.$container.'_recaptchaversion'};
+ $newversion =~ s/\D//g;
+ if ($newversion ne '2') {
+ $newversion = 1;
+ }
+ $newsettings->{'recaptchaversion'} = $newversion;
}
if (ref($current->{'recaptchakeys'}) eq 'HASH') {
$currpub = $current->{'recaptchakeys'}{'public'};
@@ -9428,6 +9486,23 @@ sub process_captcha {
}
}
}
+ if ($current->{'captcha'} eq 'recaptcha') {
+ $currversion = $current->{'recaptchaversion'};
+ if ($currversion ne '2') {
+ $currversion = 1;
+ }
+ }
+ if ($currversion ne $newversion) {
+ if ($container eq 'cancreate') {
+ if (ref($changes->{'cancreate'}) eq 'ARRAY') {
+ push(@{$changes->{'cancreate'}},'recaptchaversion');
+ } elsif (!defined($changes->{'cancreate'})) {
+ $changes->{'cancreate'} = ['recaptchaversion'];
+ }
+ } else {
+ $changes->{'recaptchaversion'} = 1;
+ }
+ }
if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
if ($container eq 'cancreate') {
if (ref($changes->{'cancreate'}) eq 'ARRAY') {
@@ -12108,6 +12183,8 @@ function updateCaptcha(caller,context) {
var pubitem;
var privtext;
var pubtext;
+ var versionitem;
+ var versiontext;
if (document.getElementById(context+'_recaptchapub')) {
pubitem = document.getElementById(context+'_recaptchapub');
} else {
@@ -12128,6 +12205,16 @@ function updateCaptcha(caller,context) {
} else {
return;
}
+ if (document.getElementById(context+'_recaptchaversion')) {
+ versionitem = document.getElementById(context+'_recaptchaversion');
+ } else {
+ return;
+ }
+ if (document.getElementById(context+'_recaptchavertxt')) {
+ versiontext = document.getElementById(context+'_recaptchavertxt');
+ } else {
+ return;
+ }
if (caller.checked) {
if (caller.value == 'recaptcha') {
pubitem.type = 'text';
@@ -12136,11 +12223,16 @@ function updateCaptcha(caller,context) {
privitem.size = '40';
pubtext.innerHTML = "$lt{'pub'}";
privtext.innerHTML = "$lt{'priv'}";
+ versionitem.type = 'text';
+ versionitem.size = '3';
+ versiontext.innerHTML = "$lt{'ver'}";
} else {
pubitem.type = 'hidden';
privitem.type = 'hidden';
+ versionitem.type = 'hidden';
pubtext.innerHTML = '';
privtext.innerHTML = '';
+ versiontext.innerHTML = '';
}
}
return;
@@ -12206,6 +12298,7 @@ sub captcha_phrases {
original => 'original (CAPTCHA)',
recaptcha => 'successor (ReCAPTCHA)',
notused => 'unused',
+ ver => 'ReCAPTCHA version (1 or 2)',
);
}