--- loncom/interface/domainprefs.pm 2019/04/26 20:15:30 1.355
+++ loncom/interface/domainprefs.pm 2019/04/26 20:22:18 1.356
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.355 2019/04/26 20:15:30 raeburn Exp $
+# $Id: domainprefs.pm,v 1.356 2019/04/26 20:22:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5822,6 +5822,7 @@ sub print_passwords {
max => 'Maximum password length',
chars => 'Required characters',
expire => 'Password expiration (days)',
+ numsaved => 'Number of previous passwords to save and disallow reuse',
);
if ($position eq 'top') {
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
@@ -6085,7 +6086,7 @@ sub print_passwords {
$itemcount ++;
}
} elsif ($position eq 'lower') {
- my ($min,$max,%chars,$expire);
+ my ($min,$max,%chars,$expire,$numsaved);
if (ref($settings) eq 'HASH') {
if ($settings->{min}) {
$min = $settings->{min};
@@ -6099,6 +6100,9 @@ sub print_passwords {
if ($settings->{expire}) {
$expire = $settings->{expire};
}
+ if ($settings->(numsaved}) {
+ $numsaved = $settings->(numsaved};
+ }
} else {
$min = '7';
}
@@ -6161,6 +6165,13 @@ sub print_passwords {
''.
' '.&mt('(Leave blank for no expiration)').''.
'';
+ $itemcount ++;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '
'.$titles{'numsaved'}.' | '.
+ ''.
+ ''.
+ ' '.&mt('(Leave blank to not save previous passwords)').''.
+ ' |
';
} else {
my $checkedon;
my $checkedoff = ' checked="checked"';
@@ -13984,6 +13995,7 @@ sub modify_passwords {
max => 'Maximum password length',
chars => 'Required characters',
expire => 'Password expiration (days)',
+ numsaved => 'Number of previous passwords to save',
reset => 'Resetting Forgotten Password',
intauth => 'Encryption of Stored Passwords (Internal Auth)',
rules => 'Rules for LON-CAPA Passwords',
@@ -14191,9 +14203,17 @@ sub modify_passwords {
$updatedefaults = 1;
}
}
- foreach my $rule ('min','max','expire') {
+ foreach my $rule ('min','max','expire','numsaved') {
$env{'form.passwords_'.$rule} =~ s/^\s+|\s+$//g;
- if ($env{'form.passwords_'.$rule} =~ /^(|\d+(|\.\d*))$/) {
+ my $ruleok;
+ if ($rule eq 'expire') {
+ if ($env{'form.passwords_'.$rule} =~ /^\d+(|\.\d*)$/) {
+ $ruleok = 1;
+ }
+ } elsif ($env{'form.passwords_'.$rule} =~ /^\d+$/) {
+ $ruleok = 1;
+ }
+ if ($ruleok) {
$newvalues{$rule} = $env{'form.passwords_'.$rule};
if (exists($current{$rule})) {
if ($newvalues{$rule} ne $current{$rule}) {
@@ -14373,13 +14393,14 @@ sub modify_passwords {
$resulttext .= ''.&mt('[_1] set to "[_2]"',$titles{$key.'_'.$item},$value).'';
}
} elsif ($key eq 'rules') {
- foreach my $rule ('min','max','expire') {
+ foreach my $rule ('min','max','expire','numsaved') {
if ($confighash{'passwords'}{$rule} eq '') {
- $resulttext .= ''.&mt('[_1] not set.',$titles{$rule});
if ($rule eq 'min') {
- $resulttext .= ' '.&mt('Default of 7 will be used');
+ $resulttext .= ''.&mt('[_1] not set.',$titles{$rule});
+ ' '.&mt('Default of 7 will be used').'';
+ } else {
+ $resulttext .= ''.&mt('[_1] set to none',$titles{$rule}).'';
}
- $resulttext .= '';
} else {
$resulttext .= ''.&mt('[_1] set to [_2]',$titles{$rule},$confighash{'passwords'}{$rule}).'';
}