Browse Source

Bug 29926: Add ability for superlibrarian to view/edit password expiration

To  test:
 1 - Sign in as a superlibrarian
 2 - Find a patron account with no password expiration set
 3 - View member detials
 4 - note expiration says 'Never'
 5 - Edit patron
 6 - Set patron expiration
 7- Save
 8 - View details, confirm password expiration shows correctly
 9 - Sign in as non-superlibrarian
10 - Confirm you don't see expirationdate on details page
11 - Edit patron and confirm password expiration does not show
12 - Edit HTML and confirm you epxiration date not saved
     <input type="text" name="password_expiration_date" value="2052-05-02">

Signed-off-by: Bob Bennhoff <bbennhoff@clicweb.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
22.05.x
Nick Clemens 2 years ago
committed by Fridolin Somers
parent
commit
6ae0b3c76c
  1. 13
      koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
  2. 10
      koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
  3. 10
      members/memberentry.pl

13
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt

@ -176,6 +176,9 @@ legend:hover {
[% IF ( ERROR_password_mismatch ) %]
<li id="ERROR_password_mismatch">Passwords do not match.</li>
[% END %]
[% IF ( ERROR_password_expiration_date ) %]
<li id="ERROR_dateexpiry">Password expiration date is invalid.</li>
[% END %]
[% IF ( ERROR_extended_unique_id_failed ) %]
<li id="ERROR_extended_unique_id_failed"><strong>[% ERROR_extended_unique_id_failed_description | html %]:</strong> Attribute value "[% ERROR_extended_unique_id_failed_value | html %]" is already in use by another patron record.</li>
[% END %]
@ -1129,7 +1132,7 @@ legend:hover {
</fieldset> <!-- /#memberentry_subscription -->
[% END # hide fieldset %]
[% UNLESS nouserid && nopassword %]
[% UNLESS nouserid && nopassword && !CanUpdatePasswordExpiration %]
<fieldset class="rows" id="memberentry_userid">
<legend id="opac_staff_login_lgd">OPAC/Staff interface login</legend>
<ol>
@ -1274,9 +1277,15 @@ legend:hover {
[% END %]
</li>
[% END # /UNLESS nopassword %]
[% UNLESS ( !CanUpdatePasswordExpiration ) %]
<li>
<label for="password_expiration_date">Password expiration date:</label>
<input type="text" id="password_expiration_date" name="password_expiration_date" maxlength="10" size="10" value="[% password_expiration_date | html %]" class="flatpickr" />
</li>
[% END %]
</ol>
</fieldset> <!-- /#memberentry_userid -->
[% END # UNLESS nouserid && nopassword %]
[% END # UNLESS nouserid && nopassword && !CanUpdatePasswordExpiration %]
<!--this zones are not necessary in modif mode -->
[% UNLESS ( opadd || opduplicate ) %]

10
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt

@ -448,6 +448,16 @@
<i class="fa fa-exclamation-circle problem" aria-hidden="true"></i> <a href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | uri %]">Undefined</a>
[% END %]
</li>
[% IF CAN_user_superlibrarian %]
<li id="patron-password_expiration_date">
<span class="label">Password expires:</span>
[% IF ( patron.password_expiration_date ) %]
[% patron.password_expiration_date | $KohaDates %]
[% ELSE %]
Never
[% END %]
</li>
[% END %]
[% IF ( patron.borrowernotes ) %]
<li id="patron-borrowernotes">

10
members/memberentry.pl

@ -92,6 +92,7 @@ my @errors;
my $borrower_data;
my $NoUpdateLogin;
my $NoUpdateEmail;
my $CanUpdatePasswordExpiration;
my $userenv = C4::Context->userenv;
my @messages;
@ -166,6 +167,9 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
if ( $patron->is_superlibrarian && !$logged_in_user->is_superlibrarian ) {
$NoUpdateEmail = 1;
}
if ($logged_in_user->is_superlibrarian) {
$CanUpdatePasswordExpiration = 1;
}
$borrower_data = $patron->unblessed;
$borrower_data->{category_type} = $patron->category->category_type;
@ -194,7 +198,7 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
}
}
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) {
next unless exists $newdata{$_};
my $userdate = $newdata{$_} or next;
@ -244,6 +248,7 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
qr/^delete_guarantor$/,
);
push @keys_to_delete, map { qr/^$_$/ } split( /\s*\|\s*/, C4::Context->preference('BorrowerUnwantedField') || q{} );
push @keys_to_delete, qr/^password_expiration_date$/ unless $CanUpdatePasswordExpiration;
for my $regexp (@keys_to_delete) {
for (keys %newdata) {
delete($newdata{$_}) if /$regexp/;
@ -792,7 +797,7 @@ if (C4::Context->preference('uppercasesurnames')) {
$data{'contactname'} &&= uc( $data{'contactname'} );
}
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) {
if ( $data{$_} ) {
$data{$_} = eval { output_pref({ dt => dt_from_string( $data{$_} ), dateonly => 1 } ); }; # back to syspref for display
}
@ -839,6 +844,7 @@ $template->param(
nok => $nok,#flag to know if an error
NoUpdateLogin => $NoUpdateLogin,
NoUpdateEmail => $NoUpdateEmail,
CanUpdatePasswordExpiration => $CanUpdatePasswordExpiration,
);
# Generate CSRF token

Loading…
Cancel
Save