--- loncom/interface/domainprefs.pm 2019/04/22 01:55:17 1.354 +++ 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.354 2019/04/22 01:55:17 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"'; @@ -13960,7 +13971,8 @@ sub modify_contacts { sub modify_passwords { my ($r,$dom,$confname,$lastactref,%domconfig) = @_; - my ($resulttext,%current,%changes,%newvalues,@oktypes,$errors,$updatedefaults); + my ($resulttext,%current,%changes,%newvalues,@oktypes,$errors, + $updatedefaults,$updateconf); my $customfn = 'resetpw.html'; if (ref($domconfig{'passwords'}) eq 'HASH') { %current = %{$domconfig{'passwords'}}; @@ -13983,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', @@ -14190,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}) { @@ -14248,6 +14269,9 @@ sub modify_passwords { $resulttext = &mt('Changes made: ').'