From 7b0bae260ac4a63e0e38e3277e0f061d6d991cac 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. --- .../bug_30700_-_add_StaffLoginResetPassword_syspref.pl | 12 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + koha-tmpl/intranet-tmpl/prog/en/includes/header.inc | 8 +++++--- koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/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 00000000000..08f1a46bb47 --- /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 581e6be18ba..1c28675f17b 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -649,6 +649,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 2e4fbb6ba90..20d7bb665ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -193,9 +193,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 c5a8c794c0f..bf9ba04fcb6 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 cb6277d4aa6..deb31afb4bd 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 @@ -193,6 +193,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 40adcfb0fc0..04dfa51377e 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' }) or ( $loggedinuser != $patron_id and C4::Context->preference('StaffLoginResetPassword') ) ) { print $input->redirect("/cgi-bin/koha/errors/404.pl"); } else { -- 2.11.0