From 60c8534b8d84772b42f8b366df57aed72fc7ffc4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 14 Feb 2022 16:34:23 +0000 Subject: [PATCH] Bug 29926: Add ability for superlibrarians to batch edit password expiration dates To test: 1 - Sign in as a superlibrarian 2 - Tools->Batch patron modification 3 - Add patrons with and without pasword expiration set 4 - Confirm dates display correctly on modification page, or show never 5 - Check the box to delete all dates 6 - Confirm patrons now show 'Never' 7 - Edit patrons again, set a date 8 - Confirm date is set correctly 9 - Sign in as a user with catalogue/tools/borrowers permissions, but not superlibrarian 10 - Confirm y9ou do not see, and cannnot edit password expiration dates Signed-off-by: Bob Bennhoff Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers --- .../prog/en/modules/tools/modborrowers.tt | 13 +++++++++++++ tools/modborrowers.pl | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index 13cf622d3c..18cf51e63a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -229,6 +229,9 @@ Mobile Registration date Expiry date + [% IF CanUpdatePasswordExpiration %] + Password expiration date + [% END %] Circulation note OPAC note Restriction expiration @@ -265,6 +268,15 @@ [% borrower.mobile | html %] [% borrower.dateenrolled | $KohaDates %] [% borrower.dateexpiry | $KohaDates %] + [% IF CanUpdatePasswordExpiration %] + [% IF borrower.password_expiration_date %] + + [% borrower.password_expiration_date | $KohaDates %] + + [% ELSE %] + Never + [% END %] + [% END %] [% borrower.borrowernotes | html %] [% borrower.opacnote | html %] [% borrower.debarred | $KohaDates %] @@ -320,6 +332,7 @@ [% CASE 'opacnote' %]OPAC note: [% CASE 'debarred' %]Restriction expiration: [% CASE 'debarredcomment' %]Restriction comment: + [% CASE 'password_expiration_date' %]Password expiration date: [% END %] [% IF ( field.type == 'text' ) %] diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index 8aed3f4b4b..bb35b8e1c0 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -51,6 +51,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $logged_in_user = Koha::Patrons->find( $loggedinuser ); +$template->param( CanUpdatePasswordExpiration => 1 ) if $logged_in_user->is_superlibrarian; + my $dbh = C4::Context->dbh; # Show borrower informations @@ -330,6 +332,8 @@ if ( $op eq 'show' ) { }, ); + push @fields, { name => "password_expiration_date", type => "date" } if $logged_in_user->is_superlibrarian; + $template->param('patron_attributes_codes', \@patron_attributes_codes); $template->param('patron_attributes_values', \@patron_attributes_values); @@ -341,16 +345,18 @@ if ( $op eq 'do' ) { my @disabled = $input->multi_param('disable_input'); my $infos; - for my $field ( qw/surname firstname branchcode categorycode streetnumber address address2 city state zipcode country email phone mobile sort1 sort2 dateenrolled dateexpiry borrowernotes opacnote debarred debarredcomment/ ) { + for my $field ( qw/surname firstname branchcode categorycode streetnumber address address2 city state zipcode country email phone mobile sort1 sort2 dateenrolled dateexpiry password_expiration_date borrowernotes opacnote debarred debarredcomment/ ) { my $value = $input->param($field); $infos->{$field} = $value if $value; $infos->{$field} = "" if grep { $_ eq $field } @disabled; } - for my $field ( qw( dateenrolled dateexpiry debarred ) ) { + for my $field ( qw( dateenrolled dateexpiry debarred password_expiration_date ) ) { $infos->{$field} = dt_from_string($infos->{$field}) if $infos->{$field}; } + delete $infos->{password_expiration_date} unless $logged_in_user->is_superlibrarian; + my @attributes = $input->multi_param('patron_attributes'); my @attr_values = $input->multi_param('patron_attributes_value'); -- 2.39.5