View | Details | Raw Unified | Return to bug 24606
Collapse All | Expand All

(-)a/cataloguing/additem.pl (-10 / +12 lines)
Lines 185-191 my $use_template_for_session = $input->param('use_template_for_session') || $inp Link Here
185
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
185
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
186
if ( $delete_template_submit ) {
186
if ( $delete_template_submit ) {
187
    my $t = Koha::Item::Templates->find($template_id);
187
    my $t = Koha::Item::Templates->find($template_id);
188
    $t->delete if $t && $t->borrowernumber eq $loggedinuser;
188
    $t->delete if $t && ( $t->borrowernumber eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) );
189
    $template_id = undef;
189
    $template_id = undef;
190
    $use_template_for_session = undef;
190
    $use_template_for_session = undef;
191
}
191
}
Lines 275-289 if ($op eq "additem") { Link Here
275
275
276
        if ($replace_template_id) {
276
        if ($replace_template_id) {
277
            my $template = Koha::Item::Templates->find($replace_template_id);
277
            my $template = Koha::Item::Templates->find($replace_template_id);
278
            if ($template) {
278
            $template->update(
279
                $template->update(
279
                {
280
                    {
280
                    id             => $replace_template_id,
281
                        id             => $replace_template_id,
281
                    is_shared      => $template_is_shared ? 1 : 0,
282
                        is_shared      => $template_is_shared ? 1 : 0,
282
                    contents       => $item->unblessed,
283
                        contents       => $item->unblessed,
283
                }
284
                    }
284
            ) if $template && (
285
                );
285
                $template->borrowernumber eq $loggedinuser
286
            }
286
                ||
287
                haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } )
288
            );
287
        }
289
        }
288
        else {
290
        else {
289
            my $template = Koha::Item::Template->new(
291
            my $template = Koha::Item::Template->new(
(-)a/installer/data/mysql/atomicupdate/bug_24606.pl (+5 lines)
Lines 19-24 return { Link Here
19
                  CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
19
                  CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
20
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21
            });
21
            });
22
23
            $dbh->do(q{
24
                INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
25
                ( 9, 'manage_item_editor_templates', 'Update and delete item editor template owned by others');
26
            });
22
        }
27
        }
23
    },
28
    },
24
};
29
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+5 lines)
Lines 353-358 Link Here
353
            Create, update and delete item groups, add or remove items from an item group
353
            Create, update and delete item groups, add or remove items from an item group
354
        </span>
354
        </span>
355
        <span class="permissioncode">([% name | html %])</span>
355
        <span class="permissioncode">([% name | html %])</span>
356
    [%- CASE 'manage_item_editor_templates' -%]
357
        <span class="sub_permission manage_item_editor_templates_subpermission">
358
            Create, update and delete item editor templates owned by others
359
        </span>
360
        <span class="permissioncode">([% name | html %])</span>
356
    [%- CASE 'remaining_permissions' -%]
361
    [%- CASE 'remaining_permissions' -%]
357
        <span class="sub_permission remaining_permissions_subpermission">
362
        <span class="sub_permission remaining_permissions_subpermission">
358
            Remaining permissions for managing fines and fees
363
            Remaining permissions for managing fines and fees
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-7 / +22 lines)
Lines 162-179 Link Here
162
            <optgroup label="My templates">
162
            <optgroup label="My templates">
163
                [% FOREACH t IN item_templates.owned %]
163
                [% FOREACH t IN item_templates.owned %]
164
                    [% IF t.id == template_id %]
164
                    [% IF t.id == template_id %]
165
                        <option data-owner="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
165
                        <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
166
                    [% ELSE %]
166
                    [% ELSE %]
167
                        <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
167
                        <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
168
                    [% END %]
168
                    [% END %]
169
                [% END %]
169
                [% END %]
170
            </optgroup>
170
            </optgroup>
171
            <optgroup label="Shared templates">
171
            <optgroup label="Shared templates">
172
                [% FOREACH t IN item_templates.shared %]
172
                [% FOREACH t IN item_templates.shared %]
173
                    [% IF t.id == template_id %]
173
                    [% IF t.id == template_id %]
174
                        <option data-owner="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
174
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
175
                            <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
176
                        [% ELSE %]
177
                            <option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
178
                        [% END %]
175
                    [% ELSE %]
179
                    [% ELSE %]
176
                        <option data-owner="0" value="[% t.id | html %]">[% t.name | html %]</option>
180
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
181
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
182
                        [% ELSE %]
183
                            <option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
184
                        [% END %]
177
                    [% END %]
185
                    [% END %]
178
                [% END %]
186
                [% END %]
179
            </optgroup>
187
            </optgroup>
Lines 255-264 Link Here
255
    <fieldset id="save_as_template_span">
263
    <fieldset id="save_as_template_span">
256
        <legend>Save template</legend>
264
        <legend>Save template</legend>
257
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
265
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
258
            <option value="0" selected="selected">Save as new</option>
266
            <option value="0" selected="selected">Save as new template</option>
259
            <optgroup label="Update existing">
267
            <optgroup label="Update existing template">
260
                [% FOREACH t IN item_templates.owned %]
268
                [% FOREACH t IN item_templates.owned %]
261
                    <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
269
                    <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
270
                [% END %]
271
                [% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %]
272
                    <optgroup label="Update shared template">
273
                        [% FOREACH t IN item_templates.shared %]
274
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
275
                        [% END %]
276
                    </optgroup>
262
                [% END %]
277
                [% END %]
263
            </optgroup>
278
            </optgroup>
264
        </select>
279
        </select>
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-2 / +1 lines)
Lines 85-91 $(document).ready(function(){ Link Here
85
    });
85
    });
86
86
87
    $("#template_id").on("change", function() {
87
    $("#template_id").on("change", function() {
88
        if ( $(this).find(":selected").data("owner") ) {
88
        if ( $(this).find(":selected").data("editor") ) {
89
            $("#delete_template_submit").removeAttr("disabled");
89
            $("#delete_template_submit").removeAttr("disabled");
90
        } else {
90
        } else {
91
            $("#delete_template_submit").attr("disabled", "disabled");
91
            $("#delete_template_submit").attr("disabled", "disabled");
92
- 

Return to bug 24606