1 package Koha::Illrequest;
3 # Copyright PTFS Europe 2016,2018
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 # Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use File::Basename qw( basename );
25 use Encode qw( encode );
31 use Koha::DateUtils qw/ dt_from_string /;
33 use Koha::Exceptions::Ill;
34 use Koha::Illcomments;
35 use Koha::Illrequestattributes;
36 use Koha::AuthorisedValue;
37 use Koha::Illrequest::Logger;
39 use Koha::AuthorisedValues;
41 use base qw(Koha::Object);
45 Koha::Illrequest - Koha Illrequest Object class
49 An ILLRequest consists of two parts; the Illrequest Koha::Object, and a series
50 of related Illrequestattributes.
52 The former encapsulates the basic necessary information that any ILL requires
53 to be usable in Koha. The latter is a set of additional properties used by
56 The former subsumes the legacy "Status" object. The latter remains
57 encapsulated in the "Record" object.
61 - Anything invoking the ->status method; annotated with:
62 + # Old use of ->status !
66 =head2 Backend API Response Principles
68 All methods should return a hashref in the following format:
74 This should be set to 1 if an error was encountered.
78 The status should be a string from the list of statuses detailed below.
82 The message is a free text field that can be passed on to the end user.
86 The value returned by the method.
90 =head2 Interface Status Messages
94 =item * branch_address_incomplete
96 An interface request has determined branch address details are incomplete.
98 =item * cancel_success
100 The interface's cancel_request method was successful in cancelling the
101 Illrequest using the API.
105 The interface's cancel_request method failed to cancel the Illrequest using
110 The interface's request method returned saying that the desired item is not
111 available for request.
119 my $statusalias = $request->statusalias;
121 Returns a request's status alias, as a Koha::AuthorisedValue instance
122 or implicit undef. This is distinct from status_alias, which only returns
123 the value in the status_alias column, this method returns the entire
124 AuthorisedValue object
130 return unless $self->status_alias;
131 # We can't know which result is the right one if there are multiple
132 # ILLSTATUS authorised values with the same authorised_value column value
133 # so we just use the first
134 return Koha::AuthorisedValues->search({
135 branchcode => $self->branchcode,
136 category => 'ILLSTATUS',
137 authorised_value => $self->SUPER::status_alias
141 =head3 illrequestattributes
145 sub illrequestattributes {
147 return Koha::Illrequestattributes->_new_from_dbic(
148 scalar $self->_result->illrequestattributes
158 return Koha::Illcomments->_new_from_dbic(
159 scalar $self->_result->illcomments
169 my $logger = Koha::Illrequest::Logger->new;
170 return $logger->get_request_logs($self);
179 return Koha::Patron->_new_from_dbic(
180 scalar $self->_result->borrowernumber
186 $Illrequest->status_alias(143);
188 Overloaded getter/setter for status_alias,
189 that only returns authorised values from the
190 correct category and records the fact that the status has changed
195 my ($self, $new_status_alias) = @_;
197 my $current_status_alias = $self->SUPER::status_alias;
199 if ($new_status_alias) {
200 # Keep a record of the previous status before we change it,
202 $self->{previous_status} = $current_status_alias ?
203 $current_status_alias :
204 scalar $self->status;
205 # This is hackery to enable us to undefine
206 # status_alias, since we need to have an overloaded
207 # status_alias method to get us around the problem described
209 # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156
210 # We need a way of accepting implied undef, so we can nullify
211 # the status_alias column, when called from $self->status
212 my $val = $new_status_alias eq "-1" ? undef : $new_status_alias;
213 my $ret = $self->SUPER::status_alias($val);
214 my $val_to_log = $val ? $new_status_alias : scalar $self->status;
216 my $logger = Koha::Illrequest::Logger->new;
217 $logger->log_status_change({
222 delete $self->{previous_status};
226 # We can't know which result is the right one if there are multiple
227 # ILLSTATUS authorised values with the same authorised_value column value
228 # so we just use the first
229 my $alias = Koha::AuthorisedValues->search({
230 branchcode => $self->branchcode,
231 category => 'ILLSTATUS',
232 authorised_value => $self->SUPER::status_alias
235 return $alias->authorised_value;
243 $Illrequest->status('CANREQ');
245 Overloaded getter/setter for request status,
246 also nullifies status_alias and records the fact that the status has changed
251 my ( $self, $new_status) = @_;
253 my $current_status = $self->SUPER::status;
254 my $current_status_alias = $self->SUPER::status_alias;
257 # Keep a record of the previous status before we change it,
259 $self->{previous_status} = $current_status_alias ?
260 $current_status_alias :
262 my $ret = $self->SUPER::status($new_status)->store;
263 if ($current_status_alias) {
264 # This is hackery to enable us to undefine
265 # status_alias, since we need to have an overloaded
266 # status_alias method to get us around the problem described
268 # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156
269 # We need a way of passing implied undef to nullify status_alias
270 # so we pass -1, which is special cased in the overloaded setter
271 $self->status_alias("-1");
273 my $logger = Koha::Illrequest::Logger->new;
274 $logger->log_status_change({
279 delete $self->{previous_status};
282 return $current_status;
288 Require "Base.pm" from the relevant ILL backend.
293 my ( $self, $backend_id ) = @_;
295 my @raw = qw/Koha Illbackends/; # Base Path
297 my $backend_name = $backend_id || $self->backend;
299 unless ( defined $backend_name && $backend_name ne '' ) {
300 Koha::Exceptions::Ill::InvalidBackendId->throw(
301 "An invalid backend ID was requested ('')");
304 my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load
305 my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name
307 $self->{_my_backend} = $backend_class->new({
308 config => $self->_config,
309 logger => Koha::Illrequest::Logger->new
317 my $backend = $abstract->_backend($new_backend);
318 my $backend = $abstract->_backend;
320 Getter/Setter for our API object.
325 my ( $self, $backend ) = @_;
326 $self->{_my_backend} = $backend if ( $backend );
327 # Dynamically load our backend object, as late as possible.
328 $self->load_backend unless ( $self->{_my_backend} );
329 return $self->{_my_backend};
332 =head3 _backend_capability
334 my $backend_capability_result = $self->_backend_capability($name, $args);
336 This is a helper method to invoke optional capabilities in the backend. If
337 the capability named by $name is not supported, return 0, else invoke it,
338 passing $args along with the invocation, and return its return value.
340 NOTE: this module suffers from a confusion in termninology:
342 in _backend_capability, the notion of capability refers to an optional feature
343 that is implemented in core, but might not be supported by a given backend.
345 in capabilities & custom_capability, capability refers to entries in the
346 status_graph (after union between backend and core).
348 The easiest way to fix this would be to fix the terminology in
349 capabilities & custom_capability and their callers.
353 sub _backend_capability {
354 my ( $self, $name, $args ) = @_;
356 # See if capability is defined in backend
358 $capability = $self->_backend->capabilities($name);
363 if ( $capability && ref($capability) eq 'CODE' ) {
364 return &{$capability}($args);
372 my $config = $abstract->_config($config);
373 my $config = $abstract->_config;
375 Getter/Setter for our config object.
380 my ( $self, $config ) = @_;
381 $self->{_my_config} = $config if ( $config );
382 # Load our config object, as late as possible.
383 unless ( $self->{_my_config} ) {
384 $self->{_my_config} = Koha::Illrequest::Config->new;
386 return $self->{_my_config};
395 return $self->_backend->metadata($self);
398 =head3 _core_status_graph
400 my $core_status_graph = $illrequest->_core_status_graph;
402 Returns ILL module's default status graph. A status graph defines the list of
403 available actions at any stage in the ILL workflow. This is for instance used
404 by the perl script & template to generate the correct buttons to display to
405 the end user at any given point.
409 sub _core_status_graph {
413 prev_actions => [ ], # Actions containing buttons
414 # leading to this status
415 id => 'NEW', # ID of this status
416 name => 'New request', # UI name of this status
417 ui_method_name => 'New request', # UI name of method leading
419 method => 'create', # method to this status
420 next_actions => [ 'REQ', 'GENREQ', 'KILL' ], # buttons to add to all
421 # requests with this status
422 ui_method_icon => 'fa-plus', # UI Style class
425 prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ],
428 ui_method_name => 'Confirm request',
430 next_actions => [ 'REQREV', 'COMP' ],
431 ui_method_icon => 'fa-check',
434 prev_actions => [ 'NEW', 'REQREV' ],
436 name => 'Requested from partners',
437 ui_method_name => 'Place request with partners',
438 method => 'generic_confirm',
439 next_actions => [ 'COMP' ],
440 ui_method_icon => 'fa-send-o',
443 prev_actions => [ 'REQ' ],
445 name => 'Request reverted',
446 ui_method_name => 'Revert Request',
448 next_actions => [ 'REQ', 'GENREQ', 'KILL' ],
449 ui_method_icon => 'fa-times',
454 name => 'Queued request',
457 next_actions => [ 'REQ', 'KILL' ],
461 prev_actions => [ 'NEW' ],
463 name => 'Cancellation requested',
466 next_actions => [ 'KILL', 'REQ' ],
470 prev_actions => [ 'REQ' ],
473 ui_method_name => 'Mark completed',
474 method => 'mark_completed',
476 ui_method_icon => 'fa-check',
479 prev_actions => [ 'QUEUED', 'REQREV', 'NEW', 'CANCREQ' ],
482 ui_method_name => 'Delete request',
485 ui_method_icon => 'fa-trash',
490 =head3 _status_graph_union
492 my $status_graph = $illrequest->_status_graph_union($origin, $new_graph);
494 Return a new status_graph, the result of merging $origin & new_graph. This is
495 operation is a union over the sets defied by the two graphs.
497 Each entry in $new_graph is added to $origin. We do not provide a syntax for
498 'subtraction' of entries from $origin.
500 Whilst it is not intended that this works, you can override entries in $origin
501 with entries with the same key in $new_graph. This can lead to problematic
502 behaviour when $new_graph adds an entry, which modifies a dependent entry in
503 $origin, only for the entry in $origin to be replaced later with a new entry
506 NOTE: this procedure does not "re-link" entries in $origin or $new_graph,
507 i.e. each of the graphs need to be correct at the outset of the operation.
511 sub _status_graph_union {
512 my ( $self, $core_status_graph, $backend_status_graph ) = @_;
513 # Create new status graph with:
514 # - all core_status_graph
515 # - for-each each backend_status_graph
516 # + add to new status graph
517 # + for each core prev_action:
518 # * locate core_status
519 # * update next_actions with additional next action.
520 # + for each core next_action:
521 # * locate core_status
522 # * update prev_actions with additional prev action
524 my @core_status_ids = keys %{$core_status_graph};
525 my $status_graph = clone($core_status_graph);
527 foreach my $backend_status_key ( keys %{$backend_status_graph} ) {
528 my $backend_status = $backend_status_graph->{$backend_status_key};
529 # Add to new status graph
530 $status_graph->{$backend_status_key} = $backend_status;
531 # Update all core methods' next_actions.
532 foreach my $prev_action ( @{$backend_status->{prev_actions}} ) {
533 if ( grep { $prev_action eq $_ } @core_status_ids ) {
535 @{$status_graph->{$prev_action}->{next_actions}};
536 push @next_actions, $backend_status_key;
537 $status_graph->{$prev_action}->{next_actions}
541 # Update all core methods' prev_actions
542 foreach my $next_action ( @{$backend_status->{next_actions}} ) {
543 if ( grep { $next_action eq $_ } @core_status_ids ) {
545 @{$status_graph->{$next_action}->{prev_actions}};
546 push @prev_actions, $backend_status_key;
547 $status_graph->{$next_action}->{prev_actions}
553 return $status_graph;
560 my $capabilities = $illrequest->capabilities;
562 Return a hashref mapping methods to operation names supported by the queried
565 Example return value:
567 { create => "Create Request", confirm => "Progress Request" }
569 NOTE: this module suffers from a confusion in termninology:
571 in _backend_capability, the notion of capability refers to an optional feature
572 that is implemented in core, but might not be supported by a given backend.
574 in capabilities & custom_capability, capability refers to entries in the
575 status_graph (after union between backend and core).
577 The easiest way to fix this would be to fix the terminology in
578 capabilities & custom_capability and their callers.
583 my ( $self, $status ) = @_;
584 # Generate up to date status_graph
585 my $status_graph = $self->_status_graph_union(
586 $self->_core_status_graph,
587 $self->_backend->status_graph({
592 # Extract available actions from graph.
593 return $status_graph->{$status} if $status;
594 # Or return entire graph.
595 return $status_graph;
598 =head3 custom_capability
600 Return the result of invoking $CANDIDATE on this request's backend with
601 $PARAMS, or 0 if $CANDIDATE is an unknown method on backend.
603 NOTE: this module suffers from a confusion in termninology:
605 in _backend_capability, the notion of capability refers to an optional feature
606 that is implemented in core, but might not be supported by a given backend.
608 in capabilities & custom_capability, capability refers to entries in the
609 status_graph (after union between backend and core).
611 The easiest way to fix this would be to fix the terminology in
612 capabilities & custom_capability and their callers.
616 sub custom_capability {
617 my ( $self, $candidate, $params ) = @_;
618 foreach my $capability ( values %{$self->capabilities} ) {
619 if ( $candidate eq $capability->{method} ) {
621 $self->_backend->$candidate({
625 return $self->expandTemplate($response);
631 =head3 available_backends
633 Return a list of available backends.
637 sub available_backends {
638 my ( $self, $reduced ) = @_;
639 my $backends = $self->_config->available_backends($reduced);
643 =head3 available_actions
645 Return a list of available actions.
649 sub available_actions {
651 my $current_action = $self->capabilities($self->status);
652 my @available_actions = map { $self->capabilities($_) }
653 @{$current_action->{next_actions}};
654 return \@available_actions;
657 =head3 mark_completed
659 Mark a request as completed (status = COMP).
665 $self->status('COMP')->store;
666 $self->completed(dt_from_string())->store;
671 method => 'mark_completed',
677 =head2 backend_migrate
679 Migrate a request from one backend to another.
683 sub backend_migrate {
684 my ( $self, $params ) = @_;
686 my $response = $self->_backend_capability('migrate',{
690 return $self->expandTemplate($response) if $response;
694 =head2 backend_confirm
696 Confirm a request. The backend handles setting of mandatory fields in the commit stage:
702 =item * accessurl, cost (if available).
708 sub backend_confirm {
709 my ( $self, $params ) = @_;
711 my $response = $self->_backend->confirm({
715 return $self->expandTemplate($response);
718 =head3 backend_update_status
722 sub backend_update_status {
723 my ( $self, $params ) = @_;
724 return $self->expandTemplate($self->_backend->update_status($params));
727 =head3 backend_cancel
729 my $ILLResponse = $illRequest->backend_cancel;
731 The standard interface method allowing for request cancellation.
736 my ( $self, $params ) = @_;
738 my $result = $self->_backend->cancel({
743 return $self->expandTemplate($result);
748 my $renew_response = $illRequest->backend_renew;
750 The standard interface method allowing for request renewal queries.
756 return $self->expandTemplate(
757 $self->_backend->renew({
763 =head3 backend_create
765 my $create_response = $abstractILL->backend_create($params);
767 Return an array of Record objects created by querying our backend with
770 In the context of the other ILL methods, this is a special method: we only
771 pass it $params, as it does not yet have any other data associated with it.
776 my ( $self, $params ) = @_;
778 # Establish whether we need to do a generic copyright clearance.
779 if ($params->{opac}) {
780 if ( ( !$params->{stage} || $params->{stage} eq 'init' )
781 && C4::Context->preference("ILLModuleCopyrightClearance") ) {
787 stage => 'copyrightclearance',
790 backend => $self->_backend->name
793 } elsif ( defined $params->{stage}
794 && $params->{stage} eq 'copyrightclearance' ) {
795 $params->{stage} = 'init';
798 # First perform API action, then...
803 my $result = $self->_backend->create($args);
805 # ... simple case: we're not at 'commit' stage.
806 my $stage = $result->{stage};
807 return $self->expandTemplate($result)
808 unless ( 'commit' eq $stage );
810 # ... complex case: commit!
812 # Do we still have space for an ILL or should we queue?
813 my $permitted = $self->check_limits(
814 { patron => $self->patron }, { librarycode => $self->branchcode }
817 # Now augment our committed request.
819 $result->{permitted} = $permitted; # Queue request?
823 # ...Updating status!
824 $self->status('QUEUED')->store unless ( $permitted );
826 ## Handle Unmediated ILLs
828 # For the unmediated workflow we only need to delegate to our backend. If
829 # that backend supports unmediateld_ill, it will do its thing and return a
830 # proper response. If it doesn't then _backend_capability returns 0, so
831 # we keep the current result.
832 if ( C4::Context->preference("ILLModuleUnmediated") && $permitted ) {
833 my $unmediated_result = $self->_backend_capability(
837 $result = $unmediated_result if $unmediated_result;
840 return $self->expandTemplate($result);
843 =head3 expandTemplate
845 my $params = $abstract->expandTemplate($params);
847 Return a version of $PARAMS augmented with our required template path.
852 my ( $self, $params ) = @_;
853 my $backend = $self->_backend->name;
854 # Generate path to file to load
855 my $backend_dir = $self->_config->backend_dir;
856 my $backend_tmpl = join "/", $backend_dir, $backend;
857 my $intra_tmpl = join "/", $backend_tmpl, "intra-includes",
858 ( $params->{method}//q{} ) . ".inc";
859 my $opac_tmpl = join "/", $backend_tmpl, "opac-includes",
860 ( $params->{method}//q{} ) . ".inc";
862 $params->{template} = $intra_tmpl;
863 $params->{opac_template} = $opac_tmpl;
867 #### Abstract Imports
871 my $limit_rules = $abstract->getLimits( {
872 type => 'brw_cat' | 'branch',
876 Return the ILL limit rules for the supplied combination of type / value.
878 As the config may have no rules for this particular type / value combination,
879 or for the default, we must define fall-back values here.
884 my ( $self, $params ) = @_;
885 my $limits = $self->_config->getLimitRules($params->{type});
887 if ( defined $params->{value}
888 && defined $limits->{$params->{value}} ) {
889 return $limits->{$params->{value}};
892 return $limits->{default} || { count => -1, method => 'active' };
898 my $prefix = $abstract->getPrefix( {
899 branch => $branch_code
902 Return the ILL prefix as defined by our $params: either per borrower category,
903 per branch or the default.
908 my ( $self, $params ) = @_;
909 my $brn_prefixes = $self->_config->getPrefixes();
910 return $brn_prefixes->{$params->{branch}} || ""; # "the empty prefix"
915 my $type = $abstract->get_type();
917 Return a string representing the material type of this request or undef
923 my $attr = $self->illrequestattributes->find({ type => 'type'});
928 #### Illrequests Imports
932 my $ok = $illRequests->check_limits( {
933 borrower => $borrower,
934 branchcode => 'branchcode' | undef,
937 Given $PARAMS, a hashref containing a $borrower object and a $branchcode,
938 see whether we are still able to place ILLs.
940 LimitRules are derived from koha-conf.xml:
941 + default limit counts, and counting method
942 + branch specific limit counts & counting method
943 + borrower category specific limit counts & counting method
944 + err on the side of caution: a counting fail will cause fail, even if
945 the other counts passes.
950 my ( $self, $params ) = @_;
951 my $patron = $params->{patron};
952 my $branchcode = $params->{librarycode} || $patron->branchcode;
954 # Establish maximum number of allowed requests
955 my ( $branch_rules, $brw_rules ) = (
962 value => $patron->categorycode,
965 my ( $branch_limit, $brw_limit )
966 = ( $branch_rules->{count}, $brw_rules->{count} );
967 # Establish currently existing requests
968 my ( $branch_count, $brw_count ) = (
969 $self->_limit_counter(
970 $branch_rules->{method}, { branchcode => $branchcode }
972 $self->_limit_counter(
973 $brw_rules->{method}, { borrowernumber => $patron->borrowernumber }
978 # A limit of -1 means no limit exists.
979 # We return blocked if either branch limit or brw limit is reached.
980 if ( ( $branch_limit != -1 && $branch_limit <= $branch_count )
981 || ( $brw_limit != -1 && $brw_limit <= $brw_count ) ) {
989 my ( $self, $method, $target ) = @_;
991 # Establish parameters of counts
993 if ($method && $method eq 'annual') {
994 $resultset = Koha::Illrequests->search({
997 \"YEAR(placed) = YEAR(NOW())"
1000 } else { # assume 'active'
1001 # XXX: This status list is ugly. There should be a method in config
1003 my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } };
1004 $resultset = Koha::Illrequests->search({ %{$target}, %{$where} });
1008 return $resultset->count;
1011 =head3 requires_moderation
1013 my $status = $illRequest->requires_moderation;
1015 Return the name of the status if moderation by staff is required; or 0
1020 sub requires_moderation {
1022 my $require_moderation = {
1023 'CANCREQ' => 'CANCREQ',
1025 return $require_moderation->{$self->status};
1028 =head3 generic_confirm
1030 my $stage_summary = $illRequest->generic_confirm;
1032 Handle the generic_confirm extended method. The first stage involves creating
1033 a template email for the end user to edit in the browser. The second stage
1034 attempts to submit the email.
1038 sub generic_confirm {
1039 my ( $self, $params ) = @_;
1040 my $branch = Koha::Libraries->find($params->{current_branchcode})
1041 || die "Invalid current branchcode. Are you logged in as the database user?";
1042 if ( !$params->{stage}|| $params->{stage} eq 'init' ) {
1043 my $draft->{subject} = "ILL Request";
1044 $draft->{body} = <<EOF;
1047 We would like to request an interlibrary loan for a title matching the
1048 following description:
1052 my $details = $self->metadata;
1053 while (my ($title, $value) = each %{$details}) {
1054 $draft->{body} .= " - " . $title . ": " . $value . "\n"
1057 $draft->{body} .= <<EOF;
1059 Please let us know if you are able to supply this to us.
1065 my @address = map { $branch->$_ }
1066 qw/ branchname branchaddress1 branchaddress2 branchaddress3
1067 branchzip branchcity branchstate branchcountry branchphone
1070 foreach my $line ( @address ) {
1071 $address .= $line . "\n" if $line;
1074 $draft->{body} .= $address;
1076 my $partners = Koha::Patrons->search({
1077 categorycode => $self->_config->partner_code
1083 method => 'generic_confirm',
1087 partners => $partners,
1091 } elsif ( 'draft' eq $params->{stage} ) {
1092 # Create the to header
1093 my $to = $params->{partners};
1094 if ( defined $to ) {
1095 $to =~ s/^\x00//; # Strip leading NULLs
1096 $to =~ s/\x00/; /; # Replace others with '; '
1098 Koha::Exceptions::Ill::NoTargetEmail->throw(
1099 "No target email addresses found. Either select at least one partner or check your ILL partner library records.")
1101 # Create the from, replyto and sender headers
1102 my $from = $branch->branchemail;
1103 my $replyto = $branch->branchreplyto || $from;
1104 Koha::Exceptions::Ill::NoLibraryEmail->throw(
1105 "Your library has no usable email address. Please set it.")
1109 my $message = Koha::Email->new;
1110 my %mail = $message->create_message_headers(
1114 replyto => $replyto,
1115 subject => Encode::encode( "utf8", $params->{subject} ),
1116 message => Encode::encode( "utf8", $params->{body} ),
1117 contenttype => 'text/plain',
1121 my $result = sendmail(%mail);
1123 $self->status("GENREQ")->store;
1124 $self->_backend_capability(
1125 'set_requested_partners',
1135 method => 'generic_confirm',
1142 status => 'email_failed',
1143 message => $Mail::Sendmail::error,
1144 method => 'generic_confirm',
1149 die "Unknown stage, should not have happened."
1155 my $prefix = $record->id_prefix;
1157 Return the prefix appropriate for the current Illrequest as derived from the
1158 borrower and branch associated with this request's Status, and the config
1165 my $prefix = $self->getPrefix( {
1166 branch => $self->branchcode,
1168 $prefix .= "-" if ( $prefix );
1174 my $params = $illRequest->_censor($params);
1176 Return $params, modified to reflect our censorship requirements.
1181 my ( $self, $params ) = @_;
1182 my $censorship = $self->_config->censorship;
1183 $params->{censor_notes_staff} = $censorship->{censor_notes_staff}
1184 if ( $params->{opac} );
1185 $params->{display_reply_date} = ( $censorship->{censor_reply_date} ) ? 0 : 1;
1194 Overloaded I<store> method that, in addition to performing the 'store',
1195 possibly records the fact that something happened
1200 my ( $self, $attrs ) = @_;
1202 my $ret = $self->SUPER::store;
1204 $attrs->{log_origin} = 'core';
1206 if ($ret && defined $attrs) {
1207 my $logger = Koha::Illrequest::Logger->new;
1208 $logger->log_maybe({
1217 =head3 requested_partners
1219 my $partners_string = $illRequest->requested_partners;
1221 Return the string representing the email addresses of the partners to
1222 whom a request has been sent
1226 sub requested_partners {
1228 return $self->_backend_capability(
1229 'get_requested_partners',
1230 { request => $self }
1236 $json = $illrequest->TO_JSON
1238 Overloaded I<TO_JSON> method that takes care of inserting calculated values
1239 into the unblessed representation of the object.
1241 TODO: This method does nothing and is not called anywhere. However, bug 74325
1242 touches it, so keeping this for now until both this and bug 74325 are merged,
1243 at which point we can sort it out and remove it completely
1248 my ( $self, $embed ) = @_;
1250 my $object = $self->SUPER::TO_JSON();
1255 =head2 Internal methods
1262 return 'Illrequest';
1267 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
1268 Andrew Isherwood <andrew.isherwood@ptfs-europe.com>