From 2c0ed4e1703f6f5d611e8712cd0cffcdfcf21748 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Thu, 30 Jan 2025 10:37:08 +0000 Subject: [PATCH] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system --- .../mysql/atomicupdate/bug_38924-patron_quotas.pl | 11 +++++++++-- installer/data/mysql/mandatory/userpermissions.sql | 2 ++ .../intranet-tmpl/prog/en/includes/permissions.inc | 6 ++++++ t/Koha/Auth/Permissions.t | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_38924-patron_quotas.pl b/installer/data/mysql/atomicupdate/bug_38924-patron_quotas.pl index 848fe85c668..a6531fbb1ab 100755 --- a/installer/data/mysql/atomicupdate/bug_38924-patron_quotas.pl +++ b/installer/data/mysql/atomicupdate/bug_38924-patron_quotas.pl @@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_success say_info); return { bug_number => "38924", - description => "Add patron quota table", + description => "Add patron quota table and permissions", up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; @@ -25,7 +25,14 @@ return { ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; } ); - say_success( $out, "Patron quota table created successfully" ); + + $dbh->do(q{ + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + (4, 'manage_borrower_quotas', 'Manage patron quotas'), + (4, 'view_borrower_quotas', 'View patron quotas') + }); + + say_success( $out, "Patron quota table and permissions created successfully" ); } else { say_info( $out, "Patron quota table already exists" ); } diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 1d8b7d034f2..6ecbf31392c 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -47,8 +47,10 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 4, 'delete_borrowers', 'Delete patrons'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'list_borrowers', 'Search, list and view patrons'), + ( 4, 'manage_borrower_quotas', 'Manage patron quotas'), ( 4, 'send_messages_to_borrowers', 'Send messages to patrons'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), + ( 4, 'view_borrower_quotas', 'View patron quotas'), ( 6, 'place_holds', 'Place holds for patrons'), ( 6, 'modify_holds_priority', 'Modify holds priority'), ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 4ca590e4b8d..ac248646218 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -544,6 +544,12 @@ [%- CASE 'marc_order_manage' -%] Manage MARC ordering ([% name | html %]) + [%- CASE 'view_borrower_quotas' -%] + View patron quotas + ([% name | html %]) + [%- CASE 'manage_borrower_quotas' -%] + Manage patron quotas + ([% name | html %]) [%- CASE 'reopen_closed_invoices' -%] Reopen closed invoices ([% name | html %]) diff --git a/t/Koha/Auth/Permissions.t b/t/Koha/Auth/Permissions.t index 108373cfb66..16eb402047f 100755 --- a/t/Koha/Auth/Permissions.t +++ b/t/Koha/Auth/Permissions.t @@ -128,6 +128,8 @@ subtest 'superlibrarian tests' => sub { 'CAN_user_borrowers_delete_borrowers' => 1, 'CAN_user_borrowers_edit_borrowers' => 1, 'CAN_user_borrowers_list_borrowers' => 1, + 'CAN_user_borrowers_manage_borrower_quotas' => 1, + 'CAN_user_borrowers_view_borrower_quotas' => 1, 'CAN_user_borrowers_view_borrower_infos_from_any_libraries' => 1, 'CAN_user_borrowers' => 1, 'CAN_user_cash_management_anonymous_refund' => 1, -- 2.48.1