[open-ils-commits] r14871 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Nov 11 16:21:37 EST 2009


Author: erickson
Date: 2009-11-11 16:21:32 -0500 (Wed, 11 Nov 2009)
New Revision: 14871

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
created a companion method to return trigger events for circ and hold event defs based on copy instead of user

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-11-11 20:19:31 UTC (rev 14870)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-11-11 21:21:32 UTC (rev 14871)
@@ -3419,7 +3419,57 @@
     return undef;
 }
 
+__PACKAGE__->register_method (
+	method		=> 'copy_events',
+	api_name    => 'open-ils.actor.copy.events.circ',
+    stream      => 1,
+);
+__PACKAGE__->register_method (
+	method		=> 'copy_events',
+	api_name    => 'open-ils.actor.copy.events.ahr',
+    stream      => 1,
+);
 
+sub copy_events {
+    my($self, $conn, $auth, $copy_id, $filters) = @_;
+    my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
+
+    (my $obj_type = $self->api_name) =~ s/.*\.([a-z]+)$/$1/;
+
+    my $copy_field = 'target_copy';
+    $copy_field = 'current_copy' if $obj_type eq 'ahr';
+
+    $filters ||= {};
+    $filters->{target} = { 
+        select => { $obj_type => ['id'] },
+        from => $obj_type,
+        where => {$copy_field => $copy_id}
+    };
+
+    my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+    my $req = $ses->request('open-ils.trigger.events_by_target', 
+        $obj_type, $filters, {atevdef => ['reactor', 'validator']}, 2);
+
+    while(my $resp = $req->recv) {
+        my $val = $resp->content;
+        my $tgt = $val->target;
+        
+        my $user = $e->retrieve_actor_user($tgt->usr);
+        if($e->requestor->id != $user->id) {
+            return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+        }
+
+        $tgt->usr($user);
+        $conn->respond($val) if $val;
+    }
+
+    return undef;
+}
+
+
+
+
 __PACKAGE__->register_method (
 	method		=> 'update_events',
 	api_name    => 'open-ils.actor.user.event.cancel.batch',



More information about the open-ils-commits mailing list