From 7fe390d81c081274e88bdd82aa3b7fbf46b3f415 Mon Sep 17 00:00:00 2001 From: wainuiwitikapark Date: Thu, 3 Apr 2025 23:39:41 +0000 Subject: [PATCH] Bug 35871: Add new subpermission merge_delete_authorities Add a new sub permission for merging and deleting authority records. Test plan: 1. Apply the patch (including bug 35870). 2. Update the database. 3. Login to the staff interface as a superlibrarian. 4. Add or edit an existing staff patron. 5. Set the patron's permissions to catalogue so they can access the staff interface. 6. Also add the edit_authorities permission, but not merge_delete_authorities. 7. Logout and log back in to the staff interface as the patron. 8. Go to Authorities. 9. Search for an authority record, for example search for 'a'. 10. Notice that there is an 'Actions' dropdown next to each authority search result. 11. Notice that the dropdown does not give you the option to choose Merge or Delete 12. Logout and log back in to the staff interface as a superlibrarian. 13. Edit the staff patron - add the sub permission merge_delete_authorities. 14. Logout and log back in to the staff interface as the staff patron. 15. Repeat steps 8 to 9. 16. Click the Action dropdown and notice you can merge. 17. Check that you can merge authority records. 18. Also check you can delete a search result that has 0 records. Sponsored-by: Education Services Australia SCIS --- authorities/merge.pl | 2 +- installer/data/mysql/atomicupdate/bug_35871.pl | 17 +++++++++++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/authorities-toolbar.inc | 6 ++++-- .../prog/en/includes/permissions.inc | 5 +++++ .../prog/en/modules/authorities/merge.tt | 5 +++++ .../en/modules/authorities/searchresultlist.tt | 2 ++ 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35871.pl diff --git a/authorities/merge.pl b/authorities/merge.pl index 3204b5c93a3..a5be7899a6a 100755 --- a/authorities/merge.pl +++ b/authorities/merge.pl @@ -39,7 +39,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( template_name => "authorities/merge.tt", query => $input, type => "intranet", - flagsrequired => { editauthorities => 1 }, + flagsrequired => { editauthorities => 'merge_delete_authorities' }, } ); diff --git a/installer/data/mysql/atomicupdate/bug_35871.pl b/installer/data/mysql/atomicupdate/bug_35871.pl new file mode 100755 index 00000000000..d1740a3a939 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35871.pl @@ -0,0 +1,17 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "35871", + description => "Add a merge_delete_authorities subpermission for editauthorities", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ('14','merge_delete_authorities','Merge and delete authority records')} + ); + + say_success( $out, "Added new permission 'merge_delete_authorities'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index bcb2fa6033a..ce2d07d42e1 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -128,6 +128,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_general_files', 'Upload any file'), (13, 'upload_manage', 'Manage uploaded files'), (14, 'edit_authorities', 'Edit authority records'), + (14, 'merge_delete_authorities', 'Merge and delete authority records'), (15, 'check_expiration', 'Check the expiration of a serial'), (15, 'claim_serials', 'Claim missing serials'), (15, 'create_subscription', 'Create a new subscription'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc index 8727903a5ff..f5fb9b428d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc @@ -26,8 +26,10 @@ [% IF servers.count > 0 %]
  • Replace record via Z39.50/SRU
  • [% END %] - [% UNLESS ( count ) %] -
  • Delete record
  • + [% IF ( CAN_user_editauthorities_merge_delete_authorities ) %] + [% UNLESS ( count ) %] +
  • Delete record
  • + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index c187a794822..43e185abd1e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -450,6 +450,11 @@ [%- CASE 'view_system_logs' -%] Browse the system logs ([% name | html %]) + [%- CASE 'merge_delete_authorities' -%] + + Merge and delete authority records + + ([% name | html %]) [%- CASE 'check_expiration' -%] Check the expiration of a serial ([% name | html %]) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt index 9f4e2a7c052..ad97a03805d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt @@ -44,6 +44,8 @@ [% WRAPPER 'main-container.inc' wide_full => 1 %]

    Merging records

    + [% IF CAN_user_editauthorities_merge_delete_authorities %] + [% IF ( errors ) %] [% FOREACH error IN errors %] @@ -137,6 +139,9 @@ [% END %] + [% ELSE %] +
    You do not have the required privileges to merge authorities.
    + [% END %] [% END %] [% MACRO jsinclude BLOCK %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt index cad44eea6e5..88221f7aacf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt @@ -109,6 +109,7 @@
  • Edit
  • + [% IF CAN_user_editauthorities_merge_delete_authorities %]
  • Merge
  • @@ -132,6 +133,7 @@ [% END %] + [% END %]
  • MARC preview
  • -- 2.39.5