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

(-)a/Koha/Illrequest/Workflow.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::Illrequest::Workflow;
1
package Koha::ILL::Request::Workflow;
2
2
3
# Copyright 2023 PTFS Europe Ltd
3
# Copyright 2023 PTFS Europe Ltd
4
#
4
#
Lines 28-34 use Koha::Plugins; Link Here
28
28
29
=head1 NAME
29
=head1 NAME
30
30
31
Koha::Illrequest::Workflow - Koha ILL Workflow parent class
31
Koha::ILL::Request::Workflow - Koha ILL Workflow parent class
32
32
33
=head1 SYNOPSIS
33
=head1 SYNOPSIS
34
34
Lines 44-52 This class contains methods do be used by ILL workflow stages Link Here
44
44
45
=head3 new
45
=head3 new
46
46
47
    my $availability = Koha::Illrequest::Workflow::Availability->new( $params, 'opac' )
47
    my $availability = Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' )
48
48
49
Create a new Koha::Illrequest::Workflow child class object.
49
Create a new Koha::ILL::Request::Workflow child class object.
50
We store the metadata and ui_context
50
We store the metadata and ui_context
51
51
52
=cut
52
=cut
Lines 65-71 sub new { Link Here
65
65
66
=head3 prep_metadata
66
=head3 prep_metadata
67
67
68
    my $prepared = Koha::Illrequest::Workflow->prep_metadata($metadata);
68
    my $prepared = Koha::ILL::Request::Workflow->prep_metadata($metadata);
69
69
70
Given our metadata, return a string representing that metadata that can be
70
Given our metadata, return a string representing that metadata that can be
71
passed in a URL (encoded in JSON then Base64 encoded)
71
passed in a URL (encoded in JSON then Base64 encoded)
(-)a/Koha/Illrequest/Workflow/Availability.pm (-6 / +6 lines)
Lines 1-4 Link Here
1
package Koha::Illrequest::Workflow::Availability;
1
package Koha::ILL::Request::Workflow::Availability;
2
2
3
# Copyright 2019 PTFS Europe Ltd
3
# Copyright 2019 PTFS Europe Ltd
4
#
4
#
Lines 21-33 use Modern::Perl; Link Here
21
21
22
use JSON;
22
use JSON;
23
23
24
use base qw(Koha::Illrequest::Workflow);
24
use base qw(Koha::ILL::Request::Workflow);
25
25
26
use Koha::Plugins;
26
use Koha::Plugins;
27
27
28
=head1 NAME
28
=head1 NAME
29
29
30
Koha::Illrequest::Workflow::Availability - Koha ILL Availability Searching
30
Koha::ILL::Request::Workflow::Availability - Koha ILL Availability Searching
31
31
32
=head1 SYNOPSIS
32
=head1 SYNOPSIS
33
33
Lines 46-52 that can be used to search for item availability Link Here
46
=head3 get_services
46
=head3 get_services
47
47
48
    my $services =
48
    my $services =
49
      Koha::Illrequest::Workflow::Availability->get_services($params);
49
      Koha::ILL::Request::Workflow::Availability->get_services($params);
50
50
51
Given our metadata, iterate plugins with the right method and
51
Given our metadata, iterate plugins with the right method and
52
check if they can service our request and, if so, return an arrayref
52
check if they can service our request and, if so, return an arrayref
Lines 82-88 sub get_services { Link Here
82
=head3 show_availability
82
=head3 show_availability
83
83
84
    my $show_availability =
84
    my $show_availability =
85
    Koha::Illrequest::Workflow::Availability->show_availability($params);
85
    Koha::ILL::Request::Workflow::Availability->show_availability($params);
86
86
87
Given $params, return true if availability should be shown
87
Given $params, return true if availability should be shown
88
88
Lines 112-118 sub show_availability { Link Here
112
=head3 availability_template_params
112
=head3 availability_template_params
113
113
114
    my $availability_template_params =
114
    my $availability_template_params =
115
    Koha::Illrequest::Workflow::Availability->availability_template_params(
115
    Koha::ILL::Request::Workflow::Availability->availability_template_params(
116
        $params);
116
        $params);
117
117
118
Given $params, return true if availability should be shown
118
Given $params, return true if availability should be shown
(-)a/Koha/Illrequest/Workflow/TypeDisclaimer.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Illrequest::Workflow::TypeDisclaimer;
1
package Koha::ILL::Request::Workflow::TypeDisclaimer;
2
2
3
# Copyright 2023 PTFS Europe Ltd
3
# Copyright 2023 PTFS Europe Ltd
4
#
4
#
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use POSIX qw( strftime );
22
use POSIX qw( strftime );
23
23
24
use base qw(Koha::Illrequest::Workflow);
24
use base qw(Koha::ILL::Request::Workflow);
25
25
26
=head1 NAME
26
=head1 NAME
27
27
Lines 129-135 sub after_request_created { Link Here
129
        value         => strftime( "%Y-%m-%dT%H:%M:%S", localtime( time() ) ),
129
        value         => strftime( "%Y-%m-%dT%H:%M:%S", localtime( time() ) ),
130
        readonly      => 0
130
        readonly      => 0
131
    };
131
    };
132
    Koha::Illrequestattribute->new($type_disclaimer_date)->store;
132
    Koha::ILL::Request::Attribute->new($type_disclaimer_date)->store;
133
133
134
    my $type_disclaimer_value = {
134
    my $type_disclaimer_value = {
135
        illrequest_id => $request->illrequest_id,
135
        illrequest_id => $request->illrequest_id,
Lines 137-143 sub after_request_created { Link Here
137
        value         => $params->{type_disclaimer_value},
137
        value         => $params->{type_disclaimer_value},
138
        readonly      => 0
138
        readonly      => 0
139
    };
139
    };
140
    Koha::Illrequestattribute->new($type_disclaimer_value)->store;
140
    Koha::ILL::Request::Attribute->new($type_disclaimer_value)->store;
141
}
141
}
142
142
143
=head3 _get_type_disclaimer_info
143
=head3 _get_type_disclaimer_info
(-)a/ill/ill-requests.pl (-6 / +6 lines)
Lines 28-35 use Koha::AuthorisedValues; Link Here
28
use Koha::ILL::Comment;
28
use Koha::ILL::Comment;
29
use Koha::Illrequests;
29
use Koha::Illrequests;
30
use Koha::ILL::Batches;
30
use Koha::ILL::Batches;
31
use Koha::Illrequest::Workflow::Availability;
31
use Koha::ILL::Request::Workflow::Availability;
32
use Koha::Illrequest::Workflow::TypeDisclaimer;
32
use Koha::ILL::Request::Workflow::TypeDisclaimer;
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Token;
34
use Koha::Token;
35
use Koha::Plugins;
35
use Koha::Plugins;
Lines 131-139 if ( $backends_available ) { Link Here
131
131
132
        # Before request creation operations - Preparation
132
        # Before request creation operations - Preparation
133
        my $availability =
133
        my $availability =
134
          Koha::Illrequest::Workflow::Availability->new( $params, 'staff' );
134
          Koha::ILL::Request::Workflow::Availability->new( $params, 'staff' );
135
        my $type_disclaimer =
135
        my $type_disclaimer =
136
          Koha::Illrequest::Workflow::TypeDisclaimer->new( $params, 'staff' );
136
        Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'staff' );
137
137
138
        # ILLCheckAvailability operation
138
        # ILLCheckAvailability operation
139
        if ($availability->show_availability($request)) {
139
        if ($availability->show_availability($request)) {
Lines 325-331 if ( $backends_available ) { Link Here
325
            # Prepare availability searching, if required
325
            # Prepare availability searching, if required
326
            # Get the definition for the z39.50 plugin
326
            # Get the definition for the z39.50 plugin
327
            if ( C4::Context->preference('ILLCheckAvailability') ) {
327
            if ( C4::Context->preference('ILLCheckAvailability') ) {
328
                my $availability = Koha::Illrequest::Workflow::Availability->new(
328
                my $availability = Koha::ILL::Request::Workflow::Availability->new(
329
                    {
329
                    {
330
                        name => 'ILL availability - z39.50',
330
                        name => 'ILL availability - z39.50',
331
                        %{$request->metadata}
331
                        %{$request->metadata}
Lines 556-562 sub get_ill_availability { Link Here
556
        }
556
        }
557
    }
557
    }
558
558
559
    my $availability = Koha::Illrequest::Workflow::Availability->new($id_types);
559
    my $availability = Koha::ILL::Request::Workflow::Availability->new($id_types);
560
    return $availability->get_services({
560
    return $availability->get_services({
561
        ui_context => 'staff'
561
        ui_context => 'staff'
562
    });
562
    });
(-)a/opac/opac-illrequests.pl (-4 / +4 lines)
Lines 31-38 use Koha::Illrequest::Config; Link Here
31
use Koha::Illrequests;
31
use Koha::Illrequests;
32
use Koha::Libraries;
32
use Koha::Libraries;
33
use Koha::Patrons;
33
use Koha::Patrons;
34
use Koha::Illrequest::Workflow::Availability;
34
use Koha::ILL::Request::Workflow::Availability;
35
use Koha::Illrequest::Workflow::TypeDisclaimer;
35
use Koha::ILL::Request::Workflow::TypeDisclaimer;
36
36
37
my $query = CGI->new;
37
my $query = CGI->new;
38
38
Lines 120-128 if ( $op eq 'list' ) { Link Here
120
120
121
        # Before request creation operations - Preparation
121
        # Before request creation operations - Preparation
122
        my $availability =
122
        my $availability =
123
          Koha::Illrequest::Workflow::Availability->new( $params, 'opac' );
123
          Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' );
124
        my $type_disclaimer =
124
        my $type_disclaimer =
125
          Koha::Illrequest::Workflow::TypeDisclaimer->new( $params, 'opac' );
125
          Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'opac' );
126
126
127
        # ILLCheckAvailability operation
127
        # ILLCheckAvailability operation
128
        if ($availability->show_availability($request)) {
128
        if ($availability->show_availability($request)) {
(-)a/t/db_dependent/Illrequest/Availability.t (-5 / +5 lines)
Lines 25-31 use Test::MockObject; Link Here
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use t::lib::Mocks;
27
27
28
use Koha::Illrequest::Workflow::Availability;
28
use Koha::ILL::Request::Workflow::Availability;
29
use Koha::Database;
29
use Koha::Database;
30
30
31
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
Lines 33-39 $schema->storage->txn_begin; Link Here
33
33
34
my $builder = t::lib::TestBuilder->new;
34
my $builder = t::lib::TestBuilder->new;
35
35
36
use_ok('Koha::Illrequest::Workflow::Availability');
36
use_ok('Koha::ILL::Request::Workflow::Availability');
37
37
38
my $metadata = {
38
my $metadata = {
39
    title  => 'This is a title',
39
    title  => 'This is a title',
Lines 48-56 foreach my $key ( keys %{$metadata} ) { Link Here
48
}
48
}
49
49
50
my $availability =
50
my $availability =
51
  Koha::Illrequest::Workflow::Availability->new( $sorted, 'staff' );
51
  Koha::ILL::Request::Workflow::Availability->new( $sorted, 'staff' );
52
52
53
isa_ok( $availability, 'Koha::Illrequest::Workflow::Availability' );
53
isa_ok( $availability, 'Koha::ILL::Request::Workflow::Availability' );
54
54
55
is(
55
is(
56
    $availability->prep_metadata($sorted),
56
    $availability->prep_metadata($sorted),
Lines 85-91 t::lib::Mocks::mock_preference( 'ILLCheckAvailability', 1 ); Link Here
85
85
86
# Mock not empty availability services
86
# Mock not empty availability services
87
my $availability_module =
87
my $availability_module =
88
  Test::MockModule->new('Koha::Illrequest::Workflow::Availability');
88
  Test::MockModule->new('Koha::ILL::Request::Workflow::Availability');
89
$availability_module->mock( 'get_services', [ { name => 'service' } ] );
89
$availability_module->mock( 'get_services', [ { name => 'service' } ] );
90
90
91
my $req_1 = $builder->build_object(
91
my $req_1 = $builder->build_object(
(-)a/t/db_dependent/Illrequest/TypeDisclaimer.t (-6 / +5 lines)
Lines 25-31 use Test::MockObject; Link Here
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use t::lib::Mocks;
27
27
28
use Koha::Illrequest::Workflow::TypeDisclaimer;
28
use Koha::ILL::Request::Workflow::TypeDisclaimer;
29
use Koha::Database;
29
use Koha::Database;
30
30
31
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
Lines 33-39 $schema->storage->txn_begin; Link Here
33
33
34
my $builder = t::lib::TestBuilder->new;
34
my $builder = t::lib::TestBuilder->new;
35
35
36
use_ok('Koha::Illrequest::Workflow::TypeDisclaimer');
36
use_ok('Koha::ILL::Request::Workflow::TypeDisclaimer');
37
37
38
my $metadata = {
38
my $metadata = {
39
    title  => 'This is a title',
39
    title  => 'This is a title',
Lines 48-56 foreach my $key ( keys %{$metadata} ) { Link Here
48
}
48
}
49
49
50
my $type_disclaimer =
50
my $type_disclaimer =
51
  Koha::Illrequest::Workflow::TypeDisclaimer->new( $sorted, 'staff' );
51
  Koha::ILL::Request::Workflow::TypeDisclaimer->new( $sorted, 'staff' );
52
52
53
isa_ok( $type_disclaimer, 'Koha::Illrequest::Workflow::TypeDisclaimer' );
53
isa_ok( $type_disclaimer, 'Koha::ILL::Request::Workflow::TypeDisclaimer' );
54
54
55
is(
55
is(
56
    $type_disclaimer->prep_metadata($sorted),
56
    $type_disclaimer->prep_metadata($sorted),
Lines 108-114 is( $type_disclaimer->show_type_disclaimer($request), Link Here
108
108
109
# Mock ILLModuleDisclaimerByType with invalid YAML
109
# Mock ILLModuleDisclaimerByType with invalid YAML
110
my $type_disclaimer_module =
110
my $type_disclaimer_module =
111
  Test::MockModule->new('Koha::Illrequest::Workflow::TypeDisclaimer');
111
  Test::MockModule->new('Koha::ILL::Request::Workflow::TypeDisclaimer');
112
$type_disclaimer_module->mock( '_get_type_disclaimer_sys_pref', {} );
112
$type_disclaimer_module->mock( '_get_type_disclaimer_sys_pref', {} );
113
113
114
is( $type_disclaimer->show_type_disclaimer($request),
114
is( $type_disclaimer->show_type_disclaimer($request),
115
- 

Return to bug 35581