From: erickson Date: Thu, 17 Aug 2006 14:49:08 +0000 (+0000) Subject: hold permit now conscious of script-builder failure events X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ad1391bb5516f6892c9f8a0f53a85ced718b02b8;p=evergreen%2Fpines.git hold permit now conscious of script-builder failure events git-svn-id: svn://svn.open-ils.org/ILS/trunk@5556 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 91ad2c222f..68e86fdfe0 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -121,6 +121,9 @@ The user does not have a valid phone number assigned + + The patron's account has expired + diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm b/Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm index 5113b975b6..f818e6fe82 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm @@ -39,38 +39,50 @@ sub permit_copy_hold { my $runner = OpenILS::Application::Circ::ScriptBuilder->build($ctx); - # check the various holdable flags - push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) - unless $U->is_true($ctx->{copy}->holdable); - - push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) - unless $U->is_true($ctx->{copy}->location->holdable); - - push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) - unless $U->is_true($ctx->{copy}->status->holdable); - - my $evt = check_age_protect($ctx->{patron}, $ctx->{copy}); - push( @allevents, $evt ) if $evt; - - $logger->debug("Running permit_copy_hold on copy " . $$params{copy}->id); - - load_scripts($runner); - my $result = $runner->run or - throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@"); - - $runner->cleanup; - - # -------------------------------------------------------------- - # Extract and uniquify the event list - # -------------------------------------------------------------- - my $events = $result->{events}; - my $pid = ($params->{patron}) ? $params->{patron}->id : $params->{patron_id}; - $logger->debug("circ_permit_hold for user $pid returned events: [@$events]"); + if( $ctx->{_events} ) { + push( @allevents, $_) for @{$ctx->{_events}}; + + # -------------------------------------------------------------- + # If scriptbuilder returned any events, then the script context + # is undefined and should not be used + # -------------------------------------------------------------- + + } else { + + # check the various holdable flags + push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) + unless $U->is_true($ctx->{copy}->holdable); + + push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) + unless $U->is_true($ctx->{copy}->location->holdable); + + push( @allevents, OpenILS::Event->new('ITEM_NOT_HOLDABLE') ) + unless $U->is_true($ctx->{copy}->status->holdable); + + my $evt = check_age_protect($ctx->{patron}, $ctx->{copy}); + push( @allevents, $evt ) if $evt; + + $logger->debug("Running permit_copy_hold on copy " . $$params{copy}->id); + + load_scripts($runner); + my $result = $runner->run or + throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@"); + + # -------------------------------------------------------------- + # Extract and uniquify the event list + # -------------------------------------------------------------- + my $events = $result->{events}; + my $pid = ($params->{patron}) ? $params->{patron}->id : $params->{patron_id}; + $logger->debug("circ_permit_hold for user $pid returned events: [@$events]"); + + push( @allevents, OpenILS::Event->new($_)) for @$events; + } - push( @allevents, OpenILS::Event->new($_)) for @$events; my %hash = map { ($_->{ilsevent} => $_) } @allevents; @allevents = values %hash; + $runner->cleanup; + return \@allevents if $$params{show_event_list}; return 1 unless @allevents; return 0;