From de17d3f230792ff0e4722e340f275c3623aba215 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 18 May 2022 04:23:55 +0000 Subject: [PATCH] Bug 30700: (follow-up) Add system preference StaffLoginResetPassword This syspref wraps around the functionality added for patrons with the 'catalogue' permission to reset their own password via the staff client. Signed-off-by: Sam Lau --- ...ug_30700_-_add_StaffLoginResetPassword_syspref.pl | 12 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + koha-tmpl/intranet-tmpl/prog/en/includes/header.inc | 8 +++++--- .../prog/en/includes/members-toolbar.inc | 2 +- .../modules/admin/preferences/staff_interface.pref | 6 ++++++ members/member-password.pl | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_30700_-_add_StaffLoginResetPassword_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_30700_-_add_StaffLoginResetPassword_syspref.pl b/installer/data/mysql/atomicupdate/bug_30700_-_add_StaffLoginResetPassword_syspref.pl new file mode 100644 index 0000000000..08f1a46bb4 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30700_-_add_StaffLoginResetPassword_syspref.pl @@ -0,0 +1,12 @@ +use Modern::Perl; + +return { + bug_number => "30700", + description => "Add new system preference StaffLoginResetPassword", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('StaffLoginResetPassword', '0', NULL, 'If enabled, patrons with access to the staff interface can change their password via the staff interface.', 'YesNo') }); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 6aed5a753e..52a6e71fb7 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -695,6 +695,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'), ('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff interface','Choice'), ('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'), +('StaffLoginResetPassword', '0', NULL, 'If enabled, patrons with access to the staff interface can change their password via the staff interface.', 'YesNo'), ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the staff interface','Integer'), ('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc index 6820c289d9..0b1548085e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -210,9 +210,11 @@ [% END %] - + [% IF Koha.Preference('StaffLoginResetPassword') %] + + [% END %]
  • Log out diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 82681b131d..9a9ced011a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -15,7 +15,7 @@ [% END %] Duplicate [% END %] - [% IF CAN_user_borrowers_edit_borrowers || patron.borrowernumber == logged_in_user.borrowernumber %] + [% IF CAN_user_borrowers_edit_borrowers || ( Koha.Preference('StaffLoginResetPassword') && patron.borrowernumber == logged_in_user.borrowernumber ) %] Change password [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref index 0e5bb27f4c..3d9b6d6f6a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -199,6 +199,12 @@ Staff interface: 1: Show 0: "Don't show" - a search field pulldown for 'Search the catalog' boxes. + - + - pref: StaffLoginResetPassword + choices: + 1: Allow + 0: "Don't allow" + - patrons with access to the staff interface (have the catalogue permission) to change their password via the staff interface. Authentication: - - pref: staffShibOnly diff --git a/members/member-password.pl b/members/member-password.pl index 40adcfb0fc..9e574b61a7 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -35,7 +35,7 @@ my ( $template, $loggedinuser, $cookie, $staffflags ) = get_template_and_user( my $patron_id = $input->param('member'); my $logged_in_user = Koha::Patrons->find( $loggedinuser ); -if ( !$logged_in_user->has_permission({ borrowers => 'edit_borrowers' }) and $loggedinuser != $patron_id ) { +if ( !$logged_in_user->has_permission({ borrowers => 'edit_borrowers' }) and ( $loggedinuser != $patron_id and C4::Context->preference('StaffLoginResetPassword') ) ) { print $input->redirect("/cgi-bin/koha/errors/404.pl"); } else { -- 2.42.0