added user version of ad-hoc A/T runner method (for receipt printing)
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 21:09:28 +0000 (21:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 21:09:28 +0000 (21:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15126 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ.pm

index 2a0fff9..f78d102 100644 (file)
@@ -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);
 
index 1fecadd..d122f12 100644 (file)
@@ -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(