From cf229bb406aacdf02c757e56c32b5f60df545d87 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 22 Oct 2025 15:18:34 +0000 Subject: [PATCH] Bug 34069: Add restore_deleted_borrowers permission and new system preference --- .../data/mysql/atomicupdate/bug_34069.pl | 22 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 3 +++ .../en/modules/admin/preferences/patrons.pref | 7 ++++++ t/Koha/Auth/Permissions.t | 1 + 6 files changed, 35 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_34069.pl diff --git a/installer/data/mysql/atomicupdate/bug_34069.pl b/installer/data/mysql/atomicupdate/bug_34069.pl new file mode 100755 index 00000000000..a401fa97767 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_34069.pl @@ -0,0 +1,22 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "34069", + description => "Add new permission restore_deleted_borrowers", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{INSERT IGNORE permissions (module_bit, code, description) VALUES (4, 'restore_deleted_borrowers', 'Restore deleted patrons')} + ); + say_success( $out, "Added new permission 'restore_deleted_borrowers'" ); + + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowDeletedPatronRestoration','0',NULL,'If enabled, allows for the restoration of deleted borrowers from the deletedborrowers table','YesNo')} + ); + + say_success( $out, "Added new system preference 'AllowDeletedPatronRestoration'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b47f27df977..0dfbb8c541d 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -29,6 +29,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AllFinesNeedOverride','1','0','If on, staff will be asked to override every fine, even if it is below noissuescharge.','YesNo'), ('AllowAllMessageDeletion','0','','Allow any Library to delete any message','YesNo'), ('AllowCheckoutNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'), +('AllowDeletedPatronRestoration', '0', NULL, 'If enabled, allows for the restoration of deleted borrowers from the deletedborrowers table','YesNo'), ('AllowFineOverride','0','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','YesNo'), ('AllowHoldDateInFuture','0','','If set a date field is displayed on the Hold screen of the Staff Interface, allowing the hold date to be set in the future.','YesNo'), ('AllowHoldItemTypeSelection','0','','If enabled, patrons and staff will be able to select the itemtype when placing a hold','YesNo'), diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 34b868d2d53..84229408866 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -52,6 +52,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 4, 'merge_borrowers', 'Merge patrons'), ( 4, 'send_messages_to_borrowers', 'Send messages to patrons'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), + ( 4, 'restore_deleted_borrowers', 'Restore deleted patrons'), ( 6, 'place_holds', 'Place holds for patrons'), ( 6, 'modify_holds_priority', 'Modify holds priority'), ( 6, 'alter_hold_targets', 'Move holds between items and records'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index e98875fc4e6..22c91108d16 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -248,6 +248,9 @@ [%- CASE 'send_messages_to_borrowers' -%] Send messages to patrons ([% name | html %]) + [%- CASE 'restore_deleted_borrowers' -%] + Restore deleted patrons + ([% name | html %]) [%- CASE 'modify_holds_priority' -%] Modify holds priority ([% name | html %]) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 533578e5b5b..0cc754bda91 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -448,6 +448,13 @@ Patrons: - days and remove anonymized patron accounts after - pref: PatronRemovalDelay - "days.
IMPORTANT: No action is performed when these delays are empty (no text). But a zero value ('0') is interpreted as no delay (do it now)! The actions are performed by the cleanup database cron job." + - + - pref: AllowDeletedPatronRestoration + choices: + 1: "Allow" + 0: "Don't allow" + - 'for the restoration of deleted borrowers from the deletedborrowers table.' + Security: - - pref: CookieConsent choices: diff --git a/t/Koha/Auth/Permissions.t b/t/Koha/Auth/Permissions.t index ed684c2ffcd..fa869c63314 100755 --- a/t/Koha/Auth/Permissions.t +++ b/t/Koha/Auth/Permissions.t @@ -131,6 +131,7 @@ subtest 'superlibrarian tests' => sub { 'CAN_user_borrowers_edit_borrowers' => 1, 'CAN_user_borrowers_list_borrowers' => 1, 'CAN_user_borrowers_api_validate_password' => 1, + 'CAN_user_borrowers_restore_deleted_borrowers' => 1, 'CAN_user_borrowers_view_borrower_infos_from_any_libraries' => 1, 'CAN_user_borrowers' => 1, 'CAN_user_cash_management_anonymous_refund' => 1, -- 2.39.5