From b3e42307e2f24d9582fff232ce3276178b536c7e Mon Sep 17 00:00:00 2001 From: Wainui Witika-Park Date: Tue, 23 Jan 2024 16:07:08 +1300 Subject: [PATCH] Bug 35870: Adding new subpermission edit_authorities Test plan: - apply patch - login to staff client with your personal user - make a new test user - set the new test user's permissions to catalogue so they can access the staff client - logout and log back in to the staff client as the new test user - go to Authorities - notice how you cannot add a new authority - logout and log back in to the staff client as your personal user - edit the new test user - add permission editauthorities and subpermission edit_authorities - logout and log back in to the staff client as the test user - go to Authorities - notice how you can now add a new authority - try adding a new authority and make sure you can edit it Sponsored-by: Education Services Australia SCIS --- authorities/authorities.pl | 2 +- ...g_35870_add_edit_authorities_subpermission | 22 +++++++++++++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/authorities-toolbar.inc | 6 ++--- .../prog/en/includes/permissions.inc | 5 +++++ .../authorities/searchresultlist-auth.tt | 4 +++- .../modules/authorities/searchresultlist.tt | 4 ++-- 7 files changed, 37 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission diff --git a/authorities/authorities.pl b/authorities/authorities.pl index bd20fd6374..92a896e64a 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -558,7 +558,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(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid, count=>$count); diff --git a/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission b/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission new file mode 100755 index 0000000000..34ed454751 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35870_add_edit_authorities_subpermission @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "35870", + description => "Adding an edit_authorities subpermission for editauthorities", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $DBversion = 'XXX'; + if( CheckVersion( $DBversion ) ) { + $dbh->do(q{INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ('14','edit_authorities','Edit authority records')}); + + NewVersion( $DBversion, undef, "Bug 35870: Add edit_authorities user subpermission" ); + } + + # Print useful stuff here + # permissions + say $out "Added new permission 'edit_authorities'"; + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 7e52abd262..da8c8ab4e9 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -119,6 +119,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 58b7ca715e..4d07f678b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc @@ -1,8 +1,8 @@ [% INCLUDE 'blocking_errors.inc' %] -[% IF ( authid || CAN_user_editauthorities) %] +[% IF ( authid || CAN_user_editauthorities_edit_authorities ) %]
- [% IF ( CAN_user_editauthorities ) %] + [% IF ( CAN_user_editauthorities_edit_authorities ) %]