From: erickson Date: Wed, 9 Dec 2009 21:09:28 +0000 (+0000) Subject: added user version of ad-hoc A/T runner method (for receipt printing) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0f4ca1b276d999e76d971c4f178f3c41ebba3cf9;p=contrib%2FConifer.git added user version of ad-hoc A/T runner method (for receipt printing) git-svn-id: svn://svn.open-ils.org/ILS/trunk@15126 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index 2a0fff9e75..f78d102ae9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -1542,6 +1542,8 @@ sub fire_object_event { } else { + $object = $$object[0] if ref $object eq 'ARRAY'; + my $event_id = $self->simplereq( 'open-ils.trigger', $auto_method, $def->id, $object, $context_org, $user_data); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 1fecadd657..d122f127e7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -1294,6 +1294,7 @@ sub test_batch_circ_events { return $U->fire_object_event($event_def, undef, $circ, $e->requestor->ws_ou) } + __PACKAGE__->register_method( method => "fire_circ_events", api_name => "open-ils.circ.fire_circ_trigger_events", @@ -1304,16 +1305,48 @@ __PACKAGE__->register_method( / ); +__PACKAGE__->register_method( + method => "fire_circ_events", + api_name => "open-ils.circ.fire_hold_trigger_events", + signature => q/ + General event def runner for hold objects. If no event def ID + is provided, the hook will be used to find the best event_def + match based on the context org unit + / +); + +__PACKAGE__->register_method( + method => "fire_circ_events", + api_name => "open-ils.circ.fire_user_trigger_events", + signature => q/ + General event def runner for user objects. If no event def ID + is provided, the hook will be used to find the best event_def + match based on the context org unit + / +); + + sub fire_circ_events { - my($self, $conn, $auth, $org_id, $event_def, $hook, $granularity, $circ_ids, $user_data) = @_; + my($self, $conn, $auth, $org_id, $event_def, $hook, $granularity, $target_ids, $user_data) = @_; my $e = new_editor(authtoken => $auth); return $e->event unless $e->checkauth; - return $e->event unless $e->allowed('VIEW_CIRCULATIONS', $org_id); - my $circs = $e->batch_retrieve_action_circulation($circ_ids); - return undef unless @$circs; - return $U->fire_object_event($event_def, $hook, $circs, $org_id, $granularity, $user_data) + my $targets; + + if($self->api_name =~ /hold/) { + return $e->event unless $e->allowed('VIEW_HOLD', $org_id); + $targets = $e->batch_retrieve_action_hold_request($target_ids); + } elsif($self->api_name =~ /user/) { + return $e->event unless $e->allowed('VIEW_USER', $org_id); + $targets = $e->batch_retrieve_actor_user($target_ids); + } else { + return $e->event unless $e->allowed('VIEW_CIRCULATIONS', $org_id); + $targets = $e->batch_retrieve_action_circulation($target_ids); + } + + return undef unless @$targets; + return $U->fire_object_event($event_def, $hook, $targets, $org_id, $granularity, $user_data) } __PACKAGE__->register_method(