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

(-)a/Koha/REST/V1/Illrequests.pm (+11 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use C4::Context;
22
use Koha::Illrequests;
23
use Koha::Illrequests;
23
use Koha::Illrequestattributes;
24
use Koha::Illrequestattributes;
24
use Koha::Libraries;
25
use Koha::Libraries;
Lines 54-62 sub list { Link Here
54
        delete $args->{embed};
55
        delete $args->{embed};
55
    }
56
    }
56
57
58
    # Get the pipe-separated string of hidden ILL statuses
59
    my $hidden_statuses_string = C4::Context->preference('ILLHiddenRequestStatuses');
60
    # Remove unwanted chars, keep numbers + ASCII letters + underscore + pipe
61
    $hidden_statuses_string =~ s/[^0-9A-Za-z_|]//g;
62
    # Turn into arrayref
63
    my $hidden_statuses = [ split /\|/, $hidden_statuses_string ];
64
57
    # Get all requests
65
    # Get all requests
58
    # If necessary, only get those from a specified patron
66
    # If necessary, only get those from a specified patron
59
    my @requests = Koha::Illrequests->search({
67
    my @requests = Koha::Illrequests->search({
68
        $hidden_statuses
69
        ? ( status => { 'not in' => $hidden_statuses } )
70
        : (),
60
        $args->{borrowernumber}
71
        $args->{borrowernumber}
61
        ? ( borrowernumber => $args->{borrowernumber} )
72
        ? ( borrowernumber => $args->{borrowernumber} )
62
        : ()
73
        : ()
(-)a/installer/data/mysql/atomicupdate/bug23391-hide-finished-ill-requests.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( q{
4
            INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
5
            VALUES ('ILLHiddenRequestStatuses',NULL,NULL,'ILL statuses that are considered finished and should not be displayed in the ILL module','multiple')
6
    });
7
8
    SetVersion( $DBversion );
9
    print "Upgrade to $DBversion done (Bug 23391 - Hide finished ILL requests)\n";
10
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 228-233 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
228
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
228
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
229
('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
229
('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
230
('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'),
230
('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'),
231
('ILLHiddenRequestStatuses', NULL, NULL, 'ILL statuses that are considered finished and should not be displayed in the ILL module', 'multiple'),
231
('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'),
232
('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'),
232
('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'),
233
('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'),
233
('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'),
234
('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+5 lines)
Lines 832-837 Circulation: Link Here
832
                  yes: Enable
832
                  yes: Enable
833
                  no: Disable
833
                  no: Disable
834
            - unmediated Interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend.
834
            - unmediated Interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend.
835
        -
836
            - "ILL statuses that are considered finished and should not be displayed in the ILL module: "
837
            - pref: ILLHiddenRequestStatuses
838
              class: multi
839
            - (separated with |). If left empty, all ILL requests will be displayed.
835
    Fines Policy:
840
    Fines Policy:
836
        -
841
        -
837
            - Calculate fines based on days overdue
842
            - Calculate fines based on days overdue
(-)a/t/db_dependent/api/v1/illrequests.t (-4 / +20 lines)
Lines 40-46 my $t = Test::Mojo->new('Koha::REST::V1'); Link Here
40
40
41
subtest 'list() tests' => sub {
41
subtest 'list() tests' => sub {
42
42
43
    plan tests => 24;
43
    plan tests => 30;
44
44
45
    # Mock ILLBackend (as object)
45
    # Mock ILLBackend (as object)
46
    my $backend = Test::MockObject->new;
46
    my $backend = Test::MockObject->new;
Lines 91-97 subtest 'list() tests' => sub { Link Here
91
            value => {
91
            value => {
92
                backend        => 'Mock',
92
                backend        => 'Mock',
93
                branchcode     => $library->branchcode,
93
                branchcode     => $library->branchcode,
94
                borrowernumber => $patron_1->borrowernumber
94
                borrowernumber => $patron_1->borrowernumber,
95
                status         => 'STATUS1',
95
            }
96
            }
96
        }
97
        }
97
    );
98
    );
Lines 129-135 subtest 'list() tests' => sub { Link Here
129
            value => {
130
            value => {
130
                backend        => 'Mock',
131
                backend        => 'Mock',
131
                branchcode     => $library->branchcode,
132
                branchcode     => $library->branchcode,
132
                borrowernumber => $patron_2->borrowernumber
133
                borrowernumber => $patron_2->borrowernumber,
134
                status         => 'STATUS2',
133
            }
135
            }
134
        }
136
        }
135
    );
137
    );
Lines 162-167 subtest 'list() tests' => sub { Link Here
162
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
164
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
163
    $t->request_ok($tx)->status_is(200)->json_is( [ $response2 ] );
165
    $t->request_ok($tx)->status_is(200)->json_is( [ $response2 ] );
164
166
167
    # Test the ILLHiddenRequestStatuses syspref
168
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'STATUS1' );
169
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
170
    $tx->req->cookies( { name => 'CGISESSID', value => $session_id } );
171
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
172
    $t->request_ok($tx)->status_is(200)
173
      ->json_is( [ $req2_formatted ] );
174
175
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'STATUS2' );
176
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
177
    $tx->req->cookies( { name => 'CGISESSID', value => $session_id } );
178
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
179
    $t->request_ok($tx)->status_is(200)
180
      ->json_is( [ $req_formatted ] );
181
165
    $schema->storage->txn_rollback;
182
    $schema->storage->txn_rollback;
166
};
183
};
167
184
168
- 

Return to bug 23391