@@ -, +, @@
---
cataloguing/additem.pl | 22 +++++++-------
.../data/mysql/atomicupdate/bug_24606.pl | 5 ++++
.../prog/en/includes/permissions.inc | 5 ++++
.../prog/en/modules/cataloguing/additem.tt | 29 ++++++++++++++-----
.../prog/js/cataloging_additem.js | 2 +-
5 files changed, 45 insertions(+), 18 deletions(-)
--- a/cataloguing/additem.pl
+++ a/cataloguing/additem.pl
@@ -185,7 +185,7 @@ my $use_template_for_session = $input->param('use_template_for_session') || $inp
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
if ( $delete_template_submit ) {
my $t = Koha::Item::Templates->find($template_id);
- $t->delete if $t && $t->borrowernumber eq $loggedinuser;
+ $t->delete if $t && ( $t->borrowernumber eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) );
$template_id = undef;
$use_template_for_session = undef;
}
@@ -275,15 +275,17 @@ if ($op eq "additem") {
if ($replace_template_id) {
my $template = Koha::Item::Templates->find($replace_template_id);
- if ($template) {
- $template->update(
- {
- id => $replace_template_id,
- is_shared => $template_is_shared ? 1 : 0,
- contents => $item->unblessed,
- }
- );
- }
+ $template->update(
+ {
+ id => $replace_template_id,
+ is_shared => $template_is_shared ? 1 : 0,
+ contents => $item->unblessed,
+ }
+ ) if $template && (
+ $template->borrowernumber eq $loggedinuser
+ ||
+ haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } )
+ );
}
else {
my $template = Koha::Item::Template->new(
--- a/installer/data/mysql/atomicupdate/bug_24606.pl
+++ a/installer/data/mysql/atomicupdate/bug_24606.pl
@@ -19,6 +19,11 @@ return {
CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
});
+
+ $dbh->do(q{
+ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
+ ( 9, 'manage_item_editor_templates', 'Update and delete item editor template owned by others');
+ });
}
},
};
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
@@ -358,6 +358,11 @@
Create, update and delete item groups, add or remove items from an item group
([% name | html %])
+ [%- CASE 'manage_item_editor_templates' -%]
+
+ Create, update and delete item editor templates owned by others
+
+ ([% name | html %])
[%- CASE 'remaining_permissions' -%]
Remaining permissions for managing fines and fees
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
@@ -168,18 +168,26 @@
@@ -261,10 +269,17 @@