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 168-185 Link Here
168
            <optgroup label="My templates">
168
            <optgroup label="My templates">
169
                [% FOREACH t IN item_templates.owned %]
169
                [% FOREACH t IN item_templates.owned %]
170
                    [% IF t.id == template_id %]
170
                    [% IF t.id == template_id %]
171
                        <option data-owner="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
171
                        <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
172
                    [% ELSE %]
172
                    [% ELSE %]
173
                        <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
173
                        <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
174
                    [% END %]
174
                    [% END %]
175
                [% END %]
175
                [% END %]
176
            </optgroup>
176
            </optgroup>
177
            <optgroup label="Shared templates">
177
            <optgroup label="Shared templates">
178
                [% FOREACH t IN item_templates.shared %]
178
                [% FOREACH t IN item_templates.shared %]
179
                    [% IF t.id == template_id %]
179
                    [% IF t.id == template_id %]
180
                        <option data-owner="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
180
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
181
                            <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
182
                        [% ELSE %]
183
                            <option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
184
                        [% END %]
181
                    [% ELSE %]
185
                    [% ELSE %]
182
                        <option data-owner="0" value="[% t.id | html %]">[% t.name | html %]</option>
186
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
187
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
188
                        [% ELSE %]
189
                            <option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
190
                        [% END %]
183
                    [% END %]
191
                    [% END %]
184
                [% END %]
192
                [% END %]
185
            </optgroup>
193
            </optgroup>
Lines 261-270 Link Here
261
    <fieldset id="save_as_template_span">
269
    <fieldset id="save_as_template_span">
262
        <legend>Save template</legend>
270
        <legend>Save template</legend>
263
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
271
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
264
            <option value="0" selected="selected">Save as new</option>
272
            <option value="0" selected="selected">Save as new template</option>
265
            <optgroup label="Update existing">
273
            <optgroup label="Update existing template">
266
                [% FOREACH t IN item_templates.owned %]
274
                [% FOREACH t IN item_templates.owned %]
267
                    <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
275
                    <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
276
                [% END %]
277
                [% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %]
278
                    <optgroup label="Update shared template">
279
                        [% FOREACH t IN item_templates.shared %]
280
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
281
                        [% END %]
282
                    </optgroup>
268
                [% END %]
283
                [% END %]
269
            </optgroup>
284
            </optgroup>
270
        </select>
285
        </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