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

(-)a/C4/Auth.pm (-1 lines)
Lines 2305-2311 sub get_cataloguing_page_permissions { Link Here
2305
        marc_modification_templates
2305
        marc_modification_templates
2306
        records_batchdel
2306
        records_batchdel
2307
        records_batchmod
2307
        records_batchmod
2308
        records_restore
2309
        stage_marc_import
2308
        stage_marc_import
2310
        upload_cover_images
2309
        upload_cover_images
2311
    );
2310
    );
(-)a/api/v1/swagger/paths/deleted_biblios.yaml (-1 / +1 lines)
Lines 206-209 Link Here
206
          $ref: "../swagger.yaml#/definitions/error"
206
          $ref: "../swagger.yaml#/definitions/error"
207
    x-koha-authorization:
207
    x-koha-authorization:
208
      permissions:
208
      permissions:
209
        tools: records_restore
209
        editcatalogue: records_restore
(-)a/api/v1/swagger/paths/deleted_items.yaml (-1 / +1 lines)
Lines 164-167 Link Here
164
          $ref: "../swagger.yaml#/definitions/error"
164
          $ref: "../swagger.yaml#/definitions/error"
165
    x-koha-authorization:
165
    x-koha-authorization:
166
      permissions:
166
      permissions:
167
        tools: records_restore
167
        editcatalogue: records_restore
(-)a/installer/data/mysql/atomicupdate/bug_17387-item_biblio-undelete.pl (-2 / +2 lines)
Lines 11-21 return { Link Here
11
        $dbh->do(
11
        $dbh->do(
12
            q{
12
            q{
13
            INSERT IGNORE INTO permissions (module_bit, code, description)
13
            INSERT IGNORE INTO permissions (module_bit, code, description)
14
            VALUES (13, 'records_restore', 'Restore deleted records')
14
            VALUES (9, 'records_restore', 'Restore deleted bibliographic records and items')
15
        }
15
        }
16
        );
16
        );
17
17
18
        say_success( $out, "Added new permission 'tools:records_restore'" );
18
        say_success( $out, "Added new permission 'editcatalogue:records_restore'" );
19
19
20
    },
20
    },
21
};
21
};
(-)a/installer/data/mysql/mandatory/userpermissions.sql (-1 / +1 lines)
Lines 70-75 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
70
   ( 9, 'edit_any_item', 'Edit any item regardless of home library'),
70
   ( 9, 'edit_any_item', 'Edit any item regardless of home library'),
71
   ( 9, 'edit_locked_records', 'Edit locked records'),
71
   ( 9, 'edit_locked_records', 'Edit locked records'),
72
   ( 9, 'set_record_sources', 'Set record source'),
72
   ( 9, 'set_record_sources', 'Set record source'),
73
   ( 9, 'records_restore', 'Restore deleted bibliographic records and items'),
73
   (10, 'payout', 'Perform account payout action'),
74
   (10, 'payout', 'Perform account payout action'),
74
   (10, 'refund', 'Perform account refund action'),
75
   (10, 'refund', 'Perform account refund action'),
75
   (10, 'discount', 'Perform account discount action'),
76
   (10, 'discount', 'Perform account discount action'),
Lines 132-138 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
132
   (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'),
133
   (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'),
133
   (13, 'marc_modification_templates', 'Manage marc modification templates'),
134
   (13, 'marc_modification_templates', 'Manage marc modification templates'),
134
   (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'),
135
   (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'),
135
   (13, 'records_restore', 'Restore deleted bibliographic records and items'),
136
   (13, 'access_files', 'Access to the files stored on the server'),
136
   (13, 'access_files', 'Access to the files stored on the server'),
137
   (13, 'upload_general_files', 'Upload any file'),
137
   (13, 'upload_general_files', 'Upload any file'),
138
   (13, 'upload_manage', 'Manage uploaded files'),
138
   (13, 'upload_manage', 'Manage uploaded files'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-menu.inc (-2 / +2 lines)
Lines 43-49 Link Here
43
        </ul>
43
        </ul>
44
    [% END %]
44
    [% END %]
45
45
46
    [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_tools_records_restore || CAN_user_tools_marc_modification_templates ) %]
46
    [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_editcatalogue_records_restore || CAN_user_tools_marc_modification_templates ) %]
47
        <h5>Batch editing</h5>
47
        <h5>Batch editing</h5>
48
        <ul>
48
        <ul>
49
            [% IF ( CAN_user_tools_items_batchmod ) %]
49
            [% IF ( CAN_user_tools_items_batchmod ) %]
Lines 71-77 Link Here
71
                    <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
71
                    <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
72
                </li>
72
                </li>
73
            [% END %]
73
            [% END %]
74
            [% IF ( CAN_user_tools_records_restore ) %]
74
            [% IF ( CAN_user_editcatalogue_records_restore ) %]
75
                <li>
75
                <li>
76
                    <a href="/cgi-bin/koha/tools/restore-records.pl">Restore deleted records</a>
76
                    <a href="/cgi-bin/koha/tools/restore-records.pl">Restore deleted records</a>
77
                </li>
77
                </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt (-2 / +2 lines)
Lines 120-126 Link Here
120
        </div>
120
        </div>
121
121
122
        <div class="col-sm-4 col-md-4">
122
        <div class="col-sm-4 col-md-4">
123
            [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_tools_records_restore || CAN_user_tools_marc_modification_templates ) %]
123
            [% IF ( CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_tools_records_batchmod || CAN_user_tools_records_batchdel || CAN_user_editcatalogue_records_restore || CAN_user_tools_marc_modification_templates ) %]
124
                <h3>Batch editing</h3>
124
                <h3>Batch editing</h3>
125
                <ul class="buttons-list">
125
                <ul class="buttons-list">
126
                    [% IF ( CAN_user_tools_items_batchmod ) %]
126
                    [% IF ( CAN_user_tools_items_batchmod ) %]
Lines 149-155 Link Here
149
                            <a class="circ-button" href="/cgi-bin/koha/tools/marc_modification_templates.pl"><i class="fa fa-gear"></i> MARC modification templates</a>
149
                            <a class="circ-button" href="/cgi-bin/koha/tools/marc_modification_templates.pl"><i class="fa fa-gear"></i> MARC modification templates</a>
150
                        </li>
150
                        </li>
151
                    [% END %]
151
                    [% END %]
152
                    [% IF ( CAN_user_tools_records_restore ) %]
152
                    [% IF ( CAN_user_editcatalogue_records_restore ) %]
153
                        <li>
153
                        <li>
154
                            <a class="circ-button" href="/cgi-bin/koha/tools/restore-records.pl"><i class="fa fa-undo"></i> Restore deleted records</a>
154
                            <a class="circ-button" href="/cgi-bin/koha/tools/restore-records.pl"><i class="fa fa-undo"></i> Restore deleted records</a>
155
                        </li>
155
                        </li>
(-)a/t/db_dependent/api/v1/deleted_biblios.t (-5 / +9 lines)
Lines 293-299 subtest 'restore() tests' => sub { Link Here
293
            source => 'UserPermission',
293
            source => 'UserPermission',
294
            value  => {
294
            value  => {
295
                borrowernumber => $librarian->borrowernumber,
295
                borrowernumber => $librarian->borrowernumber,
296
                module_bit     => 13,
296
                module_bit     => 9,
297
                code           => 'records_restore',
297
                code           => 'records_restore',
298
            }
298
            }
299
        }
299
        }
Lines 326-332 subtest 'restore() tests' => sub { Link Here
326
326
327
    $t->put_ok("//$unauth_userid:$password@/api/v1/deleted/biblios/$biblionumber")->status_is(403);
327
    $t->put_ok("//$unauth_userid:$password@/api/v1/deleted/biblios/$biblionumber")->status_is(403);
328
328
329
    $t->put_ok("//$userid:$password@/api/v1/deleted/biblios/$biblionumber")->status_is(200)
329
    $t->put_ok("//$userid:$password@/api/v1/deleted/biblios/$biblionumber")
330
        ->status_is(200)
330
        ->json_is( '/biblio_id' => $biblionumber );
331
        ->json_is( '/biblio_id' => $biblionumber );
331
332
332
    my $restored_biblio = Koha::Biblios->find($biblionumber);
333
    my $restored_biblio = Koha::Biblios->find($biblionumber);
Lines 362-368 subtest 'restore() with library group permissions tests' => sub { Link Here
362
            source => 'UserPermission',
363
            source => 'UserPermission',
363
            value  => {
364
            value  => {
364
                borrowernumber => $librarian->borrowernumber,
365
                borrowernumber => $librarian->borrowernumber,
365
                module_bit     => 13,
366
                module_bit     => 9,
366
                code           => 'records_restore',
367
                code           => 'records_restore',
367
            }
368
            }
368
        }
369
        }
Lines 413-420 subtest 'restore() with library group permissions tests' => sub { Link Here
413
414
414
    $t->put_ok(
415
    $t->put_ok(
415
        "//$userid:$password@/api/v1/deleted/biblios/$biblionumber" => { 'Content-Type' => 'application/json' } =>
416
        "//$userid:$password@/api/v1/deleted/biblios/$biblionumber" => { 'Content-Type' => 'application/json' } =>
416
            $body )->status_is(200)->json_is( '/biblio_id' => $biblionumber )
417
            $body )
417
        ->json_is( '/restored_items/0' => $item1_id )->json_is( '/skipped_items/0' => $item2_id );
418
        ->status_is(200)
419
        ->json_is( '/biblio_id'        => $biblionumber )
420
        ->json_is( '/restored_items/0' => $item1_id )
421
        ->json_is( '/skipped_items/0'  => $item2_id );
418
422
419
    my $restored_biblio = Koha::Biblios->find($biblionumber);
423
    my $restored_biblio = Koha::Biblios->find($biblionumber);
420
    ok( $restored_biblio, 'Biblio restored' );
424
    ok( $restored_biblio, 'Biblio restored' );
(-)a/t/db_dependent/api/v1/deleted_items.t (-5 / +9 lines)
Lines 120-126 subtest 'get() tests' => sub { Link Here
120
120
121
    my $non_existent_id = $item_id + 99999;
121
    my $non_existent_id = $item_id + 99999;
122
122
123
    $t->get_ok("//$userid:$password@/api/v1/deleted/items/$non_existent_id")->status_is(404)
123
    $t->get_ok("//$userid:$password@/api/v1/deleted/items/$non_existent_id")
124
        ->status_is(404)
124
        ->json_is( '/error' => 'Item not found' );
125
        ->json_is( '/error' => 'Item not found' );
125
126
126
    $schema->storage->txn_rollback;
127
    $schema->storage->txn_rollback;
Lines 147-153 subtest 'restore() tests' => sub { Link Here
147
            source => 'UserPermission',
148
            source => 'UserPermission',
148
            value  => {
149
            value  => {
149
                borrowernumber => $librarian->borrowernumber,
150
                borrowernumber => $librarian->borrowernumber,
150
                module_bit     => 13,
151
                module_bit     => 9,
151
                code           => 'records_restore',
152
                code           => 'records_restore',
152
            }
153
            }
153
        }
154
        }
Lines 196-202 subtest 'restore() tests' => sub { Link Here
196
    $item_without_biblio->delete;
197
    $item_without_biblio->delete;
197
    Koha::Biblios->find($orphan_biblio_id)->delete;
198
    Koha::Biblios->find($orphan_biblio_id)->delete;
198
199
199
    $t->put_ok("//$userid:$password@/api/v1/deleted/items/$orphan_item_id")->status_is(409)->json_has('/error')
200
    $t->put_ok("//$userid:$password@/api/v1/deleted/items/$orphan_item_id")
201
        ->status_is(409)
202
        ->json_has('/error')
200
        ->json_like( '/error', qr/Bibliographic record not found/ );
203
        ->json_like( '/error', qr/Bibliographic record not found/ );
201
204
202
    $schema->storage->txn_rollback;
205
    $schema->storage->txn_rollback;
Lines 223-229 subtest 'restore() with library group permissions tests' => sub { Link Here
223
            source => 'UserPermission',
226
            source => 'UserPermission',
224
            value  => {
227
            value  => {
225
                borrowernumber => $librarian->borrowernumber,
228
                borrowernumber => $librarian->borrowernumber,
226
                module_bit     => 13,
229
                module_bit     => 9,
227
                code           => 'records_restore',
230
                code           => 'records_restore',
228
            }
231
            }
229
        }
232
        }
Lines 262-268 subtest 'restore() with library group permissions tests' => sub { Link Here
262
    my $restored_item = Koha::Items->find($item_allowed_id);
265
    my $restored_item = Koha::Items->find($item_allowed_id);
263
    ok( $restored_item, 'Item from allowed library restored' );
266
    ok( $restored_item, 'Item from allowed library restored' );
264
267
265
    $t->put_ok("//$userid:$password@/api/v1/deleted/items/$item_restricted_id")->status_is(403)
268
    $t->put_ok("//$userid:$password@/api/v1/deleted/items/$item_restricted_id")
269
        ->status_is(403)
266
        ->json_is( '/error' => 'You do not have permission to restore items from this library.' );
270
        ->json_is( '/error' => 'You do not have permission to restore items from this library.' );
267
271
268
    my $not_restored = Koha::Items->find($item_restricted_id);
272
    my $not_restored = Koha::Items->find($item_restricted_id);
(-)a/tools/restore-records.pl (-2 / +1 lines)
Lines 31-37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
31
        template_name => "tools/restore-records.tt",
31
        template_name => "tools/restore-records.tt",
32
        query         => $input,
32
        query         => $input,
33
        type          => "intranet",
33
        type          => "intranet",
34
        flagsrequired => { tools => 'records_restore' },
34
        flagsrequired => { editcatalogue => 'records_restore' },
35
    }
35
    }
36
);
36
);
37
37
38
- 

Return to bug 17387