From 822e30989410b6a90326855438cca2cb807e4f1f 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 1. APPLY PATCH, updatedatabase, restart_all 2. Now setup two users for testing, a superlibrarian and a limited permission user. The limited permission should have staff access and the restore_deleted_borrowers (tools) permission. /* SUPERLIBRARIAN */ 3. As superlibrarian, find the 'AllowDeletedPatronRestoration' system preference and enable it. Also make sure BorrowersLog is turned on. 4. Go to Tools -> Restore deleted patrons 5. Read the warning/information about what can and cannot be restored. Ensure it all makes sense. 6. Now we must delete some borrowers, either 1 by 1 or with the batch deletion tool. 7. Back to the deletion tool ( Tools -> Restore deleted patrons ) 8. Search for some of your deleted patrons by any of the critrea available. ( Cardnumber, borrowernumber, first name, surname, category, branch, or date ) 9. Ensure that searching works well. 10. Now bring up a deleted patron, check the checbox to the left and click "Restore deleted patrons" 11. Now you should be able to see the that the patron was restored. 12. Click "View patron" to look at the restored patron record. 13. Go to the action logs and make sure that the restoration was logged. /* LIMITED PERMISSION USER */ 14. Now log in as your limited permission user. 15. Go to Tools -> Restore deleted patrons 16. As a limited permssion user you should only be able to search for deleted borrowers from your branch, or branches in your library group. 17. Repeat all the steps to restore a patron, ensuring everything works. Signed-off-by: Katie Bliss --- .../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..8d35866e136 --- /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 (13, '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 35a5d15dd8f..9c76a5581cf 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..a95fb103512 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -130,6 +130,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'), (13, 'marc_modification_templates', 'Manage marc modification templates'), (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'), + (13, 'restore_deleted_borrowers', 'Restore deleted patrons'), (13, 'access_files', 'Access to the files stored on the server'), (13, 'upload_general_files', 'Upload any file'), (13, 'upload_manage', 'Manage uploaded files'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 9aae9efba09..3c702b6c16c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -251,6 +251,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 d94bc0dd4bc..6e31e84e48c 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 @@ -454,6 +454,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