From d5f950b5f34f5166a436f0440bc0c71960ab839f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 15 May 2020 15:13:26 -0400 Subject: [PATCH] Bug 24857: Add user permission for volumes management Signed-off-by: Rebecca Coert --- api/v1/swagger/paths/biblios_volumes.json | 14 +++++----- .../data/mysql/atomicupdate/volumes.perl | 5 ++++ installer/data/mysql/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 5 ++++ .../prog/en/modules/catalogue/detail.tt | 28 +++++++++++-------- .../prog/en/modules/cataloguing/additem.tt | 2 +- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/api/v1/swagger/paths/biblios_volumes.json b/api/v1/swagger/paths/biblios_volumes.json index 2d2ef7a69e..d5dec3cb08 100644 --- a/api/v1/swagger/paths/biblios_volumes.json +++ b/api/v1/swagger/paths/biblios_volumes.json @@ -70,7 +70,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } }, "x-koha-embed": [ @@ -169,7 +169,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } } } @@ -240,7 +240,7 @@ ], "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } } }, @@ -337,7 +337,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } }, "x-koha-embed": [ @@ -409,7 +409,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } } } @@ -501,7 +501,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } }, "x-koha-embed": [ @@ -585,7 +585,7 @@ }, "x-koha-authorization": { "permissions": { - "catalogue": "1" + "catalogue": "CAN_user_editcatalogue_manage_volumes" } } } diff --git a/installer/data/mysql/atomicupdate/volumes.perl b/installer/data/mysql/atomicupdate/volumes.perl index 7f60669fe8..c1886b3087 100644 --- a/installer/data/mysql/atomicupdate/volumes.perl +++ b/installer/data/mysql/atomicupdate/volumes.perl @@ -5,6 +5,11 @@ if ( CheckVersion( $DBversion ) ) { ('EnableVolumes','0','','Enable volumes feature','YesNo'); }); + $dbh->do(q{ + INSERT INTO permissions (module_bit, code, description) VALUES + ( 9, 'manage_volumes', 'Create, update and delete volumes, add or remove items from a volume'); + }); + unless ( TableExists('volumes') ) { $dbh->do(q{ CREATE TABLE `volumes` ( -- information related to bibliographic records in Koha diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 0224a56a79..08987dad1e 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -46,6 +46,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 9, 'edit_items', 'Edit items'), ( 9, 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)'), ( 9, 'delete_all_items', 'Delete all items at once'), + ( 9, 'manage_volumes', 'Create, update and delete volumes, add or remove items from a volume'), (10, 'payout', 'Perform account payout action'), (10, 'refund', 'Perform account refund action'), (10, 'discount', 'Perform account discount action'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 79b6560193..1214e1c195 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -315,6 +315,11 @@ Fast cataloging ([% name | html %]) + [%- CASE 'manage_volumes' -%] + + Create, update and delete volumes, add or remove items from a volume + + ([% name | html %]) [%- CASE 'remaining_permissions' -%] Remaining permissions for managing fines and fees diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index a38321d386..e1c3bcb68a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -279,7 +279,7 @@ [% IF CAN_user_tools_items_batchmod %] Modify selected items [% END %] - [% IF biblio.volumes.count %] + [% IF CAN_user_editcatalogue_manage_volumes && biblio.volumes.count %] Add/move to volume Remove from volume [% END %] @@ -552,9 +552,11 @@ Note that permanent location is a code, and location may be an authval. [% IF Koha.Preference('EnableVolumes') %]
- + [% IF CAN_user_editcatalogue_manage_volumes %] + + [% END %] @@ -1444,13 +1446,17 @@ Note that permanent location is a code, and location may be an authval. }, { "mDataProp": function( oObj ) { - return `` - + ' ' - + ``; + [% IF CAN_user_editcatalogue_manage_volumes %] + return `` + + ' ' + + ``; + [% ELSE %] + return ""; + [% END %] }, }, ], diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 3ad5bb6bb7..3a7ceca22f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -234,7 +234,7 @@ -[% IF volumes.count && op != 'saveitem' %] +[% IF volumes.count && op != 'saveitem' && CAN_user_editcatalogue_manage_volumes %]
Add to volume [% FOREACH v IN volumes %] -- 2.24.1 (Apple Git-126)