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

(-)a/cataloguing/additem.pl (-10 / +12 lines)
Lines 186-192 my $use_template_for_session = $input->param('use_template_for_session') || $inp Link Here
186
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
186
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
187
if ( $delete_template_submit ) {
187
if ( $delete_template_submit ) {
188
    my $t = Koha::Item::Templates->find($template_id);
188
    my $t = Koha::Item::Templates->find($template_id);
189
    $t->delete if $t && $t->borrowernumber eq $loggedinuser;
189
    $t->delete if $t && ( $t->borrowernumber eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) );
190
    $template_id = undef;
190
    $template_id = undef;
191
    $use_template_for_session = undef;
191
    $use_template_for_session = undef;
192
}
192
}
Lines 276-290 if ($op eq "additem") { Link Here
276
276
277
        if ($replace_template_id) {
277
        if ($replace_template_id) {
278
            my $template = Koha::Item::Templates->find($replace_template_id);
278
            my $template = Koha::Item::Templates->find($replace_template_id);
279
            if ($template) {
279
            $template->update(
280
                $template->update(
280
                {
281
                    {
281
                    id             => $replace_template_id,
282
                        id             => $replace_template_id,
282
                    is_shared      => $template_is_shared ? 1 : 0,
283
                        is_shared      => $template_is_shared ? 1 : 0,
283
                    contents       => $item->unblessed,
284
                        contents       => $item->unblessed,
284
                }
285
                    }
285
            ) if $template && (
286
                );
286
                $template->borrowernumber eq $loggedinuser
287
            }
287
                ||
288
                haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } )
289
            );
288
        }
290
        }
289
        else {
291
        else {
290
            my $template = Koha::Item::Template->new(
292
            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 361-366 Link Here
361
            Create, update and delete item groups, add or remove items from an item group
361
            Create, update and delete item groups, add or remove items from an item group
362
        </span>
362
        </span>
363
        <span class="permissioncode">([% name | html %])</span>
363
        <span class="permissioncode">([% name | html %])</span>
364
    [%- CASE 'manage_item_editor_templates' -%]
365
        <span class="sub_permission manage_item_editor_templates_subpermission">
366
            Create, update and delete item editor templates owned by others
367
        </span>
368
        <span class="permissioncode">([% name | html %])</span>
364
    [%- CASE 'remaining_permissions' -%]
369
    [%- CASE 'remaining_permissions' -%]
365
        <span class="sub_permission remaining_permissions_subpermission">
370
        <span class="sub_permission remaining_permissions_subpermission">
366
            Remaining permissions for managing fines and fees
371
            Remaining permissions for managing fines and fees
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-7 / +22 lines)
Lines 169-186 Link Here
169
            <optgroup label="My templates">
169
            <optgroup label="My templates">
170
                [% FOREACH t IN item_templates.owned %]
170
                [% FOREACH t IN item_templates.owned %]
171
                    [% IF t.id == template_id %]
171
                    [% IF t.id == template_id %]
172
                        <option data-owner="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
172
                        <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
173
                    [% ELSE %]
173
                    [% ELSE %]
174
                        <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
174
                        <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
175
                    [% END %]
175
                    [% END %]
176
                [% END %]
176
                [% END %]
177
            </optgroup>
177
            </optgroup>
178
            <optgroup label="Shared templates">
178
            <optgroup label="Shared templates">
179
                [% FOREACH t IN item_templates.shared %]
179
                [% FOREACH t IN item_templates.shared %]
180
                    [% IF t.id == template_id %]
180
                    [% IF t.id == template_id %]
181
                        <option data-owner="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
181
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
182
                            <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
183
                        [% ELSE %]
184
                            <option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
185
                        [% END %]
182
                    [% ELSE %]
186
                    [% ELSE %]
183
                        <option data-owner="0" value="[% t.id | html %]">[% t.name | html %]</option>
187
                        [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
188
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
189
                        [% ELSE %]
190
                            <option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
191
                        [% END %]
184
                    [% END %]
192
                    [% END %]
185
                [% END %]
193
                [% END %]
186
            </optgroup>
194
            </optgroup>
Lines 262-271 Link Here
262
    <fieldset id="save_as_template_span">
270
    <fieldset id="save_as_template_span">
263
        <legend>Save template</legend>
271
        <legend>Save template</legend>
264
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
272
        <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
265
            <option value="0" selected="selected">Save as new</option>
273
            <option value="0" selected="selected">Save as new template</option>
266
            <optgroup label="Update existing">
274
            <optgroup label="Update existing template">
267
                [% FOREACH t IN item_templates.owned %]
275
                [% FOREACH t IN item_templates.owned %]
268
                    <option data-owner="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
276
                    <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
277
                [% END %]
278
                [% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %]
279
                    <optgroup label="Update shared template">
280
                        [% FOREACH t IN item_templates.shared %]
281
                            <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
282
                        [% END %]
283
                    </optgroup>
269
                [% END %]
284
                [% END %]
270
            </optgroup>
285
            </optgroup>
271
        </select>
286
        </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