Bugzilla – Attachment 194248 Details for
Bug 17387
Add an undelete feature for items/biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17387: (follow-up) move records_restore under editcatalogue permission
4ccc5f6.patch (text/plain), 12.98 KB, created by
Martin Renvoize (ashimema)
on 2026-03-01 17:06:33 UTC
(
hide
)
Description:
Bug 17387: (follow-up) move records_restore under editcatalogue permission
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-03-01 17:06:33 UTC
Size:
12.98 KB
patch
obsolete
>From 4ccc5f6d175d724a997e27ba52c90389abf244f1 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Sun, 1 Mar 2026 16:58:37 +0000 >Subject: [PATCH] Bug 17387: (follow-up) move records_restore under > editcatalogue permission >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The restore functionality is a cataloguing operation and should live >under the editcatalogue permission module (bit 9) rather than tools >(bit 13), consistent with where it appears in the UI. > >Update all references: >- userpermissions.sql and atomicupdate: module_bit 13 â 9 >- Swagger x-koha-authorization: tools â editcatalogue >- CGI flagsrequired: tools â editcatalogue >- Templates: CAN_user_tools_records_restore â CAN_user_editcatalogue_records_restore >- C4::Auth::get_cataloguing_page_permissions: remove from tools > sub-perms list (editcatalogue '*' already covers it) >- Tests: module_bit 13 â 9 > >Signed-off-by: Michaela <michaela.sieber@kit.edu> >Sponsored-by: ByWater Solutions >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > C4/Auth.pm | 1 - > api/v1/swagger/paths/deleted_biblios.yaml | 2 +- > api/v1/swagger/paths/deleted_items.yaml | 2 +- > .../atomicupdate/bug_17387-item_biblio-undelete.pl | 4 ++-- > installer/data/mysql/mandatory/userpermissions.sql | 2 +- > .../intranet-tmpl/prog/en/includes/cat-menu.inc | 4 ++-- > .../prog/en/modules/cataloguing/cataloging-home.tt | 4 ++-- > t/db_dependent/api/v1/deleted_biblios.t | 14 +++++++++----- > t/db_dependent/api/v1/deleted_items.t | 14 +++++++++----- > tools/restore-records.pl | 2 +- > 10 files changed, 28 insertions(+), 21 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index a6bb73d79ca..b5308ae4a42 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -2305,7 +2305,6 @@ 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 117ac1521a6..cf290da7783 100644 >--- a/api/v1/swagger/paths/deleted_biblios.yaml >+++ b/api/v1/swagger/paths/deleted_biblios.yaml >@@ -206,4 +206,4 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- tools: records_restore >+ editcatalogue: records_restore >diff --git a/api/v1/swagger/paths/deleted_items.yaml b/api/v1/swagger/paths/deleted_items.yaml >index f0196d7f8cf..fab57604430 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: >- tools: records_restore >+ editcatalogue: 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 >index 35080c8079d..44f92f26d32 100755 >--- a/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl >+++ b/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl >@@ -11,11 +11,11 @@ return { > $dbh->do( > q{ > INSERT IGNORE INTO permissions (module_bit, code, description) >- VALUES (13, 'records_restore', 'Restore deleted records') >+ VALUES (9, 'records_restore', 'Restore deleted bibliographic records and items') > } > ); > >- say_success( $out, "Added new permission 'tools:records_restore'" ); >+ say_success( $out, "Added new permission 'editcatalogue:records_restore'" ); > > }, > }; >diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql >index bd9e2b373d8..35f02b0fc66 100644 >--- a/installer/data/mysql/mandatory/userpermissions.sql >+++ b/installer/data/mysql/mandatory/userpermissions.sql >@@ -70,6 +70,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > ( 9, 'edit_any_item', 'Edit any item regardless of home library'), > ( 9, 'edit_locked_records', 'Edit locked records'), > ( 9, 'set_record_sources', 'Set record source'), >+ ( 9, 'records_restore', 'Restore deleted bibliographic records and items'), > (10, 'payout', 'Perform account payout action'), > (10, 'refund', 'Perform account refund action'), > (10, 'discount', 'Perform account discount action'), >@@ -132,7 +133,6 @@ 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 bibliographic records and items'), > (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/cat-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-menu.inc >index 5ebcbdc3297..deecefa3a7d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-menu.inc >@@ -43,7 +43,7 @@ > </ul> > [% END %] > >- [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_tools_records_restore || CAN_user_tools_marc_modification_templates ) %] >+ [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_editcatalogue_records_restore || CAN_user_tools_marc_modification_templates ) %] > <h5>Batch editing</h5> > <ul> > [% IF ( CAN_user_tools_items_batchmod ) %] >@@ -71,7 +71,7 @@ > <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a> > </li> > [% END %] >- [% IF ( CAN_user_tools_records_restore ) %] >+ [% IF ( CAN_user_editcatalogue_records_restore ) %] > <li> > <a href="/cgi-bin/koha/tools/restore-records.pl">Restore deleted records</a> > </li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt >index c7ad12c9e49..def483e0ea3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt >@@ -120,7 +120,7 @@ > </div> > > <div class="col-sm-4 col-md-4"> >- [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_tools_records_restore || CAN_user_tools_marc_modification_templates ) %] >+ [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_editcatalogue_records_restore || CAN_user_tools_marc_modification_templates ) %] > <h3>Batch editing</h3> > <ul class="buttons-list"> > [% IF ( CAN_user_tools_items_batchmod ) %] >@@ -149,7 +149,7 @@ > <a class="circ-button" href="/cgi-bin/koha/tools/marc_modification_templates.pl"><i class="fa fa-gear"></i> MARC modification templates</a> > </li> > [% END %] >- [% IF ( CAN_user_tools_records_restore ) %] >+ [% IF ( CAN_user_editcatalogue_records_restore ) %] > <li> > <a class="circ-button" href="/cgi-bin/koha/tools/restore-records.pl"><i class="fa fa-undo"></i> Restore deleted records</a> > </li> >diff --git a/t/db_dependent/api/v1/deleted_biblios.t b/t/db_dependent/api/v1/deleted_biblios.t >index daf7f30c0ef..1a734546f1c 100755 >--- a/t/db_dependent/api/v1/deleted_biblios.t >+++ b/t/db_dependent/api/v1/deleted_biblios.t >@@ -293,7 +293,7 @@ subtest 'restore() tests' => sub { > source => 'UserPermission', > value => { > borrowernumber => $librarian->borrowernumber, >- module_bit => 13, >+ module_bit => 9, > code => 'records_restore', > } > } >@@ -326,7 +326,8 @@ subtest 'restore() tests' => sub { > > $t->put_ok("//$unauth_userid:$password@/api/v1/deleted/biblios/$biblionumber")->status_is(403); > >- $t->put_ok("//$userid:$password@/api/v1/deleted/biblios/$biblionumber")->status_is(200) >+ $t->put_ok("//$userid:$password@/api/v1/deleted/biblios/$biblionumber") >+ ->status_is(200) > ->json_is( '/biblio_id' => $biblionumber ); > > my $restored_biblio = Koha::Biblios->find($biblionumber); >@@ -362,7 +363,7 @@ subtest 'restore() with library group permissions tests' => sub { > source => 'UserPermission', > value => { > borrowernumber => $librarian->borrowernumber, >- module_bit => 13, >+ module_bit => 9, > code => 'records_restore', > } > } >@@ -413,8 +414,11 @@ subtest 'restore() with library group permissions tests' => sub { > > $t->put_ok( > "//$userid:$password@/api/v1/deleted/biblios/$biblionumber" => { 'Content-Type' => 'application/json' } => >- $body )->status_is(200)->json_is( '/biblio_id' => $biblionumber ) >- ->json_is( '/restored_items/0' => $item1_id )->json_is( '/skipped_items/0' => $item2_id ); >+ $body ) >+ ->status_is(200) >+ ->json_is( '/biblio_id' => $biblionumber ) >+ ->json_is( '/restored_items/0' => $item1_id ) >+ ->json_is( '/skipped_items/0' => $item2_id ); > > my $restored_biblio = Koha::Biblios->find($biblionumber); > ok( $restored_biblio, 'Biblio restored' ); >diff --git a/t/db_dependent/api/v1/deleted_items.t b/t/db_dependent/api/v1/deleted_items.t >index 76514504cf7..a3aabbbfb91 100755 >--- a/t/db_dependent/api/v1/deleted_items.t >+++ b/t/db_dependent/api/v1/deleted_items.t >@@ -120,7 +120,8 @@ subtest 'get() tests' => sub { > > my $non_existent_id = $item_id + 99999; > >- $t->get_ok("//$userid:$password@/api/v1/deleted/items/$non_existent_id")->status_is(404) >+ $t->get_ok("//$userid:$password@/api/v1/deleted/items/$non_existent_id") >+ ->status_is(404) > ->json_is( '/error' => 'Item not found' ); > > $schema->storage->txn_rollback; >@@ -147,7 +148,7 @@ subtest 'restore() tests' => sub { > source => 'UserPermission', > value => { > borrowernumber => $librarian->borrowernumber, >- module_bit => 13, >+ module_bit => 9, > code => 'records_restore', > } > } >@@ -196,7 +197,9 @@ subtest 'restore() tests' => sub { > $item_without_biblio->delete; > Koha::Biblios->find($orphan_biblio_id)->delete; > >- $t->put_ok("//$userid:$password@/api/v1/deleted/items/$orphan_item_id")->status_is(409)->json_has('/error') >+ $t->put_ok("//$userid:$password@/api/v1/deleted/items/$orphan_item_id") >+ ->status_is(409) >+ ->json_has('/error') > ->json_like( '/error', qr/Bibliographic record not found/ ); > > $schema->storage->txn_rollback; >@@ -223,7 +226,7 @@ subtest 'restore() with library group permissions tests' => sub { > source => 'UserPermission', > value => { > borrowernumber => $librarian->borrowernumber, >- module_bit => 13, >+ module_bit => 9, > code => 'records_restore', > } > } >@@ -262,7 +265,8 @@ subtest 'restore() with library group permissions tests' => sub { > my $restored_item = Koha::Items->find($item_allowed_id); > ok( $restored_item, 'Item from allowed library restored' ); > >- $t->put_ok("//$userid:$password@/api/v1/deleted/items/$item_restricted_id")->status_is(403) >+ $t->put_ok("//$userid:$password@/api/v1/deleted/items/$item_restricted_id") >+ ->status_is(403) > ->json_is( '/error' => 'You do not have permission to restore items from this library.' ); > > my $not_restored = Koha::Items->find($item_restricted_id); >diff --git a/tools/restore-records.pl b/tools/restore-records.pl >index ef83c80957b..caebeb64e76 100755 >--- a/tools/restore-records.pl >+++ b/tools/restore-records.pl >@@ -31,7 +31,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > template_name => "tools/restore-records.tt", > query => $input, > type => "intranet", >- flagsrequired => { tools => 'records_restore' }, >+ flagsrequired => { editcatalogue => 'records_restore' }, > } > ); > >-- >2.53.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17387
:
188670
|
188671
|
188672
|
188673
|
188674
|
188675
|
188676
|
188677
|
188678
|
188679
|
188680
|
188681
|
188682
|
188683
|
188684
|
188685
|
188686
|
188687
|
188688
|
188689
|
188690
|
188691
|
188692
|
188693
|
188694
|
188695
|
188696
|
188697
|
188698
|
188699
|
188700
|
188701
|
188780
|
188781
|
188782
|
188783
|
188784
|
188785
|
188786
|
188787
|
188788
|
188789
|
188790
|
188791
|
188792
|
188793
|
188794
|
188795
|
189046
|
189047
|
189048
|
189049
|
189050
|
189051
|
189052
|
189053
|
189054
|
189055
|
189056
|
189057
|
189058
|
189059
|
189060
|
189061
|
189062
|
189082
|
189083
|
189084
|
189085
|
189086
|
189087
|
189088
|
189089
|
189090
|
189091
|
189092
|
189093
|
189094
|
189095
|
189096
|
189097
|
189098
|
189099
|
189100
|
189101
|
189102
|
189103
|
189104
|
189105
|
189106
|
189107
|
189108
|
189109
|
189110
|
189111
|
189112
|
189113
|
189114
|
189115
|
189116
|
189117
|
189118
|
189119
|
194228
|
194229
|
194230
|
194231
|
194232
|
194233
|
194234
|
194235
|
194236
|
194237
|
194238
|
194239
|
194240
|
194241
|
194242
|
194243
|
194244
|
194245
|
194246
|
194247
| 194248