From 1b6433de16ef6c8d856de8245714a25e65b258e8 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Thu, 30 Oct 2025 13:16:51 +0000 Subject: [PATCH] Bug 17387: add restore records permission as child of cataloguing perms --- C4/Auth.pm | 1 + api/v1/swagger/paths/deleted_biblios.yaml | 2 +- api/v1/swagger/paths/deleted_items.yaml | 2 +- .../bug_17387-item_biblio-undelete.pl | 21 +++++++++++++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 3 +++ tools/restore-records.pl | 2 +- 7 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl diff --git a/C4/Auth.pm b/C4/Auth.pm index 20242735e1a..c42dfe82f79 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -2370,6 +2370,7 @@ sub get_cataloguing_page_permissions { marc_modification_templates records_batchdel records_batchmod + records_restore stage_marc_import upload_cover_images ); diff --git a/api/v1/swagger/paths/deleted_biblios.yaml b/api/v1/swagger/paths/deleted_biblios.yaml index f86913c8f53..4f62a0e3907 100644 --- a/api/v1/swagger/paths/deleted_biblios.yaml +++ b/api/v1/swagger/paths/deleted_biblios.yaml @@ -171,4 +171,4 @@ $ref: "../swagger.yaml#/definitions/error" x-koha-authorization: permissions: - editcatalogue: edit_catalogue + tools: records_restore diff --git a/api/v1/swagger/paths/deleted_items.yaml b/api/v1/swagger/paths/deleted_items.yaml index 6b108b5a4c0..f0196d7f8cf 100644 --- a/api/v1/swagger/paths/deleted_items.yaml +++ b/api/v1/swagger/paths/deleted_items.yaml @@ -164,4 +164,4 @@ $ref: "../swagger.yaml#/definitions/error" x-koha-authorization: permissions: - editcatalogue: edit_catalogue + tools: records_restore diff --git a/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl b/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl new file mode 100755 index 00000000000..35080c8079d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl @@ -0,0 +1,21 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "17387", + description => "Add records_restore permission", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO permissions (module_bit, code, description) + VALUES (13, 'records_restore', 'Restore deleted records') + } + ); + + say_success( $out, "Added new permission 'tools:records_restore'" ); + + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 509cfd79f38..fe2a210ab0a 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -129,6 +129,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, 'records_restore', 'Restore deleted records'), (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 8cb47687a64..ff69b05343c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -445,6 +445,9 @@ [%- CASE 'records_batchmod' -%] Perform batch modification of records (biblios or authorities) ([% name | html %]) + [%- CASE 'records_restore' -%] + Restore deleted records + ([% name | html %]) [%- CASE 'rotating_collections' -%] Manage rotating collections ([% name | html %]) diff --git a/tools/restore-records.pl b/tools/restore-records.pl index b3133f2cf18..41d5dbb5888 100755 --- a/tools/restore-records.pl +++ b/tools/restore-records.pl @@ -29,7 +29,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "tools/restore-records.tt", query => $input, type => "intranet", - flagsrequired => { editcatalogue => 'edit_catalogue' }, + flagsrequired => { tools => 'records_restore' }, } ); -- 2.39.5