Bugzilla – Attachment 141617 Details for
Bug 24606
Allow storing item values as a template for creating new items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24606: Add item template editor permission
Bug-24606-Add-item-template-editor-permission.patch (text/plain), 8.43 KB, created by
Kyle M Hall (khall)
on 2022-10-11 16:49:16 UTC
(
hide
)
Description:
Bug 24606: Add item template editor permission
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-10-11 16:49:16 UTC
Size:
8.43 KB
patch
obsolete
>From 6c8ecf0a47059e3ef14f55632a9cb720a53668ca Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Thu, 6 Oct 2022 10:08:45 -0400 >Subject: [PATCH] Bug 24606: Add item template editor permission > >--- > 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(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index aceacf118b..c5f701a0b7 100755 >--- a/cataloguing/additem.pl >+++ b/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( >diff --git a/installer/data/mysql/atomicupdate/bug_24606.pl b/installer/data/mysql/atomicupdate/bug_24606.pl >index 76406122d9..18b0eba217 100755 >--- a/installer/data/mysql/atomicupdate/bug_24606.pl >+++ b/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'); >+ }); > } > }, > }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >index 917f228a4c..67c56efa6c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -353,6 +353,11 @@ > Create, update and delete item groups, add or remove items from an item group > </span> > <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'manage_item_editor_templates' -%] >+ <span class="sub_permission manage_item_editor_templates_subpermission"> >+ Create, update and delete item editor templates owned by others >+ </span> >+ <span class="permissioncode">([% name | html %])</span> > [%- CASE 'remaining_permissions' -%] > <span class="sub_permission remaining_permissions_subpermission"> > Remaining permissions for managing fines and fees >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 79798df826..dab321a8cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -162,18 +162,26 @@ > <optgroup label="My templates"> > [% FOREACH t IN item_templates.owned %] > [% IF t.id == template_id %] >- <option data-owner="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> >+ <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> > [% ELSE %] >- <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> >+ <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> > [% END %] > [% END %] > </optgroup> > <optgroup label="Shared templates"> > [% FOREACH t IN item_templates.shared %] > [% IF t.id == template_id %] >- <option data-owner="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option> >+ [% IF CAN_user_editcatalogue_manage_item_editor_templates %] >+ <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option> >+ [% ELSE %] >+ <option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option> >+ [% END %] > [% ELSE %] >- <option data-owner="0" value="[% t.id | html %]">[% t.name | html %]</option> >+ [% IF CAN_user_editcatalogue_manage_item_editor_templates %] >+ <option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option> >+ [% ELSE %] >+ <option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option> >+ [% END %] > [% END %] > [% END %] > </optgroup> >@@ -255,10 +263,17 @@ > <fieldset id="save_as_template_span"> > <legend>Save template</legend> > <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em"> >- <option value="0" selected="selected">Save as new</option> >- <optgroup label="Update existing"> >+ <option value="0" selected="selected">Save as new template</option> >+ <optgroup label="Update existing template"> > [% FOREACH t IN item_templates.owned %] >- <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> >+ <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> >+ [% END %] >+ [% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %] >+ <optgroup label="Update shared template"> >+ [% FOREACH t IN item_templates.shared %] >+ <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option> >+ [% END %] >+ </optgroup> > [% END %] > </optgroup> > </select> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >index 1364cd3277..6cd4af50e5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >@@ -85,7 +85,7 @@ $(document).ready(function(){ > }); > > $("#template_id").on("change", function() { >- if ( $(this).find(":selected").data("owner") ) { >+ if ( $(this).find(":selected").data("editor") ) { > $("#delete_template_submit").removeAttr("disabled"); > } else { > $("#delete_template_submit").attr("disabled", "disabled"); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24606
:
141613
|
141614
|
141615
|
141616
|
141617
|
141717
|
141718
|
141719
|
141720
|
141721
|
141972
|
142003
|
142004
|
142005
|
142006
|
142007
|
142008
|
142833
|
142834
|
142835
|
142836
|
142837
|
142877
|
142878
|
142879
|
142880
|
142881
|
142882
|
142883
|
142884
|
142885
|
142886
|
142887
|
142888
|
143020
|
143569
|
143570
|
143571
|
143572
|
143573
|
143574
|
143575
|
143576
|
143577
|
143578
|
143579
|
143580
|
143581
|
143794
|
143795
|
143796
|
143989
|
143990
|
144161