From f9f90e902b729580d783daf505a85ccde6fb71e0 Mon Sep 17 00:00:00 2001 From: Wainui Witika-Park Date: Tue, 23 Jan 2024 16:07:08 +1300 Subject: [PATCH] Bug 35870: Add new subpermission edit_authorities Add a new sub permission for authority records - this will enbale the adding other granular permssions in future bugs, such as deleting and editing authority records. Test plan: 1. Apply the patch. 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. Logout and log back in to the staff interface as the patron. 7. Go to Authorities. 8. Notice how you cannot add a new authority record. 9. Logout and log back in to the staff interface as a superlibrarian. 10. Edit the staff patron - add permission editauthorities and sub permission edit_authorities. 11. Logout and log back in to the staff interface as the staff patron. 12. Go to Authorities. 13. Notice how you can now add a new authority record. 14. Try adding a new authority record and make sure you can edit it. Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind --- authorities/authorities.pl | 2 +- ..._35870_add_edit_authorities_subpermission.pl | 17 +++++++++++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/authorities-toolbar.inc | 6 +++--- .../prog/en/includes/permissions.inc | 5 +++++ .../authorities/searchresultlist-auth.tt | 4 +++- .../en/modules/authorities/searchresultlist.tt | 4 ++-- 7 files changed, 32 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission.pl diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 2133008f4f..a5f980566f 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -567,7 +567,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/authorities.tt", query => $input, type => "intranet", - flagsrequired => {editauthorities => 1}, + flagsrequired => { editauthorities => 'edit_authorities' }, }); $template->param( index => $myindex, authtypecode => $authtypecode, breedingid => $breedingid, count => $count ); diff --git a/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission.pl b/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission.pl new file mode 100755 index 0000000000..f22fd49b84 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission.pl @@ -0,0 +1,17 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "35870", + description => "Adding an edit_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','edit_authorities','Edit authority records')} + ); + + say_success( $out, "Added new permission 'edit_authorities'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 1d8b7d034f..bcb2fa6033 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -127,6 +127,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server'), (13, 'upload_general_files', 'Upload any file'), (13, 'upload_manage', 'Manage uploaded files'), + (14, 'edit_authorities', 'Edit 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 0858140aa2..fa69af6634 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc @@ -1,7 +1,7 @@ -[% IF ( authid || CAN_user_editauthorities) %] +[% IF ( authid || CAN_user_editauthorities_edit_authorities ) %]
- [% IF ( CAN_user_editauthorities ) %] + [% IF ( CAN_user_editauthorities_edit_authorities ) %]