From 6ae0b3c76c418a3b8ca90d7ff7b87e839a25a2af Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 14 Feb 2022 16:01:07 +0000 Subject: [PATCH] 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 Signed-off-by: Bob Bennhoff Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers --- .../prog/en/modules/members/memberentrygen.tt | 13 +++++++++++-- .../prog/en/modules/members/moremember.tt | 10 ++++++++++ members/memberentry.pl | 10 ++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index d01b2316bc..e61ae4f688 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -176,6 +176,9 @@ legend:hover { [% IF ( ERROR_password_mismatch ) %]
  • Passwords do not match.
  • [% END %] + [% IF ( ERROR_password_expiration_date ) %] +
  • Password expiration date is invalid.
  • + [% END %] [% IF ( ERROR_extended_unique_id_failed ) %]
  • [% ERROR_extended_unique_id_failed_description | html %]: Attribute value "[% ERROR_extended_unique_id_failed_value | html %]" is already in use by another patron record.
  • [% END %] @@ -1129,7 +1132,7 @@ legend:hover { [% END # hide fieldset %] - [% UNLESS nouserid && nopassword %] + [% UNLESS nouserid && nopassword && !CanUpdatePasswordExpiration %]
    OPAC/Staff interface login
      @@ -1274,9 +1277,15 @@ legend:hover { [% END %] [% END # /UNLESS nopassword %] + [% UNLESS ( !CanUpdatePasswordExpiration ) %] +
    1. + + +
    2. + [% END %]
    - [% END # UNLESS nouserid && nopassword %] + [% END # UNLESS nouserid && nopassword && !CanUpdatePasswordExpiration %] [% UNLESS ( opadd || opduplicate ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 292f754c04..dfd08255f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -448,6 +448,16 @@ Undefined [% END %] + [% IF CAN_user_superlibrarian %] +
  • + Password expires: + [% IF ( patron.password_expiration_date ) %] + [% patron.password_expiration_date | $KohaDates %] + [% ELSE %] + Never + [% END %] +
  • + [% END %] [% IF ( patron.borrowernotes ) %]
  • diff --git a/members/memberentry.pl b/members/memberentry.pl index 4e25891dd0..0f369ebc21 100755 --- a/members/memberentry.pl +++ b/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 -- 2.39.5