From: erickson Date: Wed, 11 Nov 2009 21:21:32 +0000 (+0000) Subject: created a companion method to return trigger events for circ and hold event defs... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a601edc10fc1377170a00e87185df6617f7ea018;p=evergreen%2Fpines.git created a companion method to return trigger events for circ and hold event defs based on copy instead of user git-svn-id: svn://svn.open-ils.org/ILS/trunk@14871 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 94f7bfd702..5ee73bafe8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -3419,6 +3419,56 @@ sub user_events { 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',