|
Lines 18-25
package Koha::Illrequest;
Link Here
|
| 18 |
# Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin |
18 |
# Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin |
| 19 |
# Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
# Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 |
|
20 |
|
| 21 |
# use Modern::Perl; |
|
|
| 22 |
|
| 23 |
use Clone 'clone'; |
21 |
use Clone 'clone'; |
| 24 |
use File::Basename qw/basename/; |
22 |
use File::Basename qw/basename/; |
| 25 |
use Koha::Database; |
23 |
use Koha::Database; |
|
Lines 29-34
use Koha::Illrequestattributes;
Link Here
|
| 29 |
use Koha::Patron; |
27 |
use Koha::Patron; |
| 30 |
use Mail::Sendmail; |
28 |
use Mail::Sendmail; |
| 31 |
use Try::Tiny; |
29 |
use Try::Tiny; |
|
|
30 |
use Modern::Perl; |
| 32 |
|
31 |
|
| 33 |
use base qw(Koha::Object); |
32 |
use base qw(Koha::Object); |
| 34 |
|
33 |
|
|
Lines 59-64
TODO:
Link Here
|
| 59 |
|
58 |
|
| 60 |
All methods should return a hashref in the following format: |
59 |
All methods should return a hashref in the following format: |
| 61 |
|
60 |
|
|
|
61 |
=over |
| 62 |
|
| 62 |
=item * error |
63 |
=item * error |
| 63 |
|
64 |
|
| 64 |
This should be set to 1 if an error was encountered. |
65 |
This should be set to 1 if an error was encountered. |
|
Lines 75-81
The message is a free text field that can be passed on to the end user.
Link Here
|
| 75 |
|
76 |
|
| 76 |
The value returned by the method. |
77 |
The value returned by the method. |
| 77 |
|
78 |
|
| 78 |
=over |
79 |
=back |
| 79 |
|
80 |
|
| 80 |
=head2 Interface Status Messages |
81 |
=head2 Interface Status Messages |
| 81 |
|
82 |
|
|
Lines 100-107
the API.
Link Here
|
| 100 |
The interface's request method returned saying that the desired item is not |
101 |
The interface's request method returned saying that the desired item is not |
| 101 |
available for request. |
102 |
available for request. |
| 102 |
|
103 |
|
|
|
104 |
=back |
| 105 |
|
| 103 |
=head2 Class methods |
106 |
=head2 Class methods |
| 104 |
|
107 |
|
|
|
108 |
=head3 illrequestattributes |
| 109 |
|
| 105 |
=cut |
110 |
=cut |
| 106 |
|
111 |
|
| 107 |
sub illrequestattributes { |
112 |
sub illrequestattributes { |
|
Lines 111-116
sub illrequestattributes {
Link Here
|
| 111 |
); |
116 |
); |
| 112 |
} |
117 |
} |
| 113 |
|
118 |
|
|
|
119 |
=head3 patron |
| 120 |
|
| 121 |
=cut |
| 122 |
|
| 114 |
sub patron { |
123 |
sub patron { |
| 115 |
my ( $self ) = @_; |
124 |
my ( $self ) = @_; |
| 116 |
return Koha::Patron->_new_from_dbic( |
125 |
return Koha::Patron->_new_from_dbic( |
|
Lines 118-131
sub patron {
Link Here
|
| 118 |
); |
127 |
); |
| 119 |
} |
128 |
} |
| 120 |
|
129 |
|
|
|
130 |
=head3 load_backend |
| 131 |
|
| 132 |
Require "Base.pm" from the relevant ILL backend. |
| 133 |
|
| 134 |
=cut |
| 135 |
|
| 121 |
sub load_backend { |
136 |
sub load_backend { |
| 122 |
my ( $self, $backend_id ) = @_; |
137 |
my ( $self, $backend_id ) = @_; |
| 123 |
|
138 |
|
| 124 |
my @raw = qw/Koha Illbackends/; # Base Path |
139 |
my @raw = qw/Koha Illbackends/; # Base Path |
| 125 |
|
140 |
|
| 126 |
my $backend_name = $backend_id || $self->backend; |
141 |
my $backend_name = $backend_id || $self->backend; |
| 127 |
$location = join "/", @raw, $backend_name, "Base.pm"; # File to load |
142 |
my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load |
| 128 |
$backend_class = join "::", @raw, $backend_name, "Base"; # Package name |
143 |
my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name |
| 129 |
require $location; |
144 |
require $location; |
| 130 |
$self->{_my_backend} = $backend_class->new({ config => $self->_config }); |
145 |
$self->{_my_backend} = $backend_class->new({ config => $self->_config }); |
| 131 |
return $self; |
146 |
return $self; |
|
Lines 342-348
sub _status_graph_union {
Link Here
|
| 342 |
my $status_graph = clone($core_status_graph); |
357 |
my $status_graph = clone($core_status_graph); |
| 343 |
|
358 |
|
| 344 |
foreach my $backend_status_key ( keys %{$backend_status_graph} ) { |
359 |
foreach my $backend_status_key ( keys %{$backend_status_graph} ) { |
| 345 |
$backend_status = $backend_status_graph->{$backend_status_key}; |
360 |
my $backend_status = $backend_status_graph->{$backend_status_key}; |
| 346 |
# Add to new status graph |
361 |
# Add to new status graph |
| 347 |
$status_graph->{$backend_status_key} = $backend_status; |
362 |
$status_graph->{$backend_status_key} = $backend_status; |
| 348 |
# Update all core methods' next_actions. |
363 |
# Update all core methods' next_actions. |
|
Lines 445-459
sub custom_capability {
Link Here
|
| 445 |
return 0; |
460 |
return 0; |
| 446 |
} |
461 |
} |
| 447 |
|
462 |
|
|
|
463 |
=head3 available_backends |
| 464 |
|
| 465 |
Return a list of available backends. |
| 466 |
|
| 467 |
=cut |
| 468 |
|
| 448 |
sub available_backends { |
469 |
sub available_backends { |
| 449 |
my ( $self ) = @_; |
470 |
my ( $self ) = @_; |
| 450 |
my $backend_dir = $self->_config->backend_dir; |
471 |
my $backend_dir = $self->_config->backend_dir; |
| 451 |
my @backends = (); |
472 |
my @backends = (); |
| 452 |
@backends = <$backend_dir/*> if ( $backend_dir ); |
473 |
@backends = glob "$backend_dir/*" if ( $backend_dir ); |
| 453 |
@backends = map { basename($_) } @backends; |
474 |
@backends = map { basename($_) } @backends; |
| 454 |
return \@backends; |
475 |
return \@backends; |
| 455 |
} |
476 |
} |
| 456 |
|
477 |
|
|
|
478 |
=head3 available_actions |
| 479 |
|
| 480 |
Return a list of available actions. |
| 481 |
|
| 482 |
=cut |
| 483 |
|
| 457 |
sub available_actions { |
484 |
sub available_actions { |
| 458 |
my ( $self ) = @_; |
485 |
my ( $self ) = @_; |
| 459 |
my $current_action = $self->capabilities($self->status); |
486 |
my $current_action = $self->capabilities($self->status); |
|
Lines 462-467
sub available_actions {
Link Here
|
| 462 |
return \@available_actions; |
489 |
return \@available_actions; |
| 463 |
} |
490 |
} |
| 464 |
|
491 |
|
|
|
492 |
=head3 mark_completed |
| 493 |
|
| 494 |
Mark a request as completed (status = COMP). |
| 495 |
|
| 496 |
=cut |
| 497 |
|
| 465 |
sub mark_completed { |
498 |
sub mark_completed { |
| 466 |
my ( $self ) = @_; |
499 |
my ( $self ) = @_; |
| 467 |
$self->status('COMP')->store; |
500 |
$self->status('COMP')->store; |
|
Lines 475-486
sub mark_completed {
Link Here
|
| 475 |
}; |
508 |
}; |
| 476 |
} |
509 |
} |
| 477 |
|
510 |
|
|
|
511 |
=head2 backend_confirm |
| 512 |
|
| 513 |
Confirm a request. The backend handles setting of mandatory fields in the commit stage: |
| 514 |
|
| 515 |
=over |
| 516 |
|
| 517 |
=item * orderid |
| 518 |
|
| 519 |
=item * accessurl, cost (if available). |
| 520 |
|
| 521 |
=back |
| 522 |
|
| 523 |
=cut |
| 524 |
|
| 478 |
sub backend_confirm { |
525 |
sub backend_confirm { |
| 479 |
my ( $self, $params ) = @_; |
526 |
my ( $self, $params ) = @_; |
| 480 |
|
527 |
|
| 481 |
# The backend handles setting of mandatory fields in the commit stage: |
|
|
| 482 |
# - orderid |
| 483 |
# - accessurl, cost (if available). |
| 484 |
my $response = $self->_backend->confirm({ |
528 |
my $response = $self->_backend->confirm({ |
| 485 |
request => $self, |
529 |
request => $self, |
| 486 |
other => $params, |
530 |
other => $params, |
|
Lines 488-493
sub backend_confirm {
Link Here
|
| 488 |
return $self->expandTemplate($response); |
532 |
return $self->expandTemplate($response); |
| 489 |
} |
533 |
} |
| 490 |
|
534 |
|
|
|
535 |
=head3 backend_update_status |
| 536 |
|
| 537 |
=cut |
| 538 |
|
| 491 |
sub backend_update_status { |
539 |
sub backend_update_status { |
| 492 |
my ( $self, $params ) = @_; |
540 |
my ( $self, $params ) = @_; |
| 493 |
return $self->expandTemplate($self->_backend->update_status($params)); |
541 |
return $self->expandTemplate($self->_backend->update_status($params)); |
|
Lines 739-745
sub _limit_counter {
Link Here
|
| 739 |
} else { # assume 'active' |
787 |
} else { # assume 'active' |
| 740 |
# XXX: This status list is ugly. There should be a method in config |
788 |
# XXX: This status list is ugly. There should be a method in config |
| 741 |
# to return these. |
789 |
# to return these. |
| 742 |
$where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } }; |
790 |
my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } }; |
| 743 |
$resultset = Koha::Illrequests->search({ %{$target}, %{$where} }); |
791 |
$resultset = Koha::Illrequests->search({ %{$target}, %{$where} }); |
| 744 |
} |
792 |
} |
| 745 |
|
793 |
|