[open-ils-commits] r12619 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 19 16:29:36 EDT 2009
Author: erickson
Date: 2009-03-19 16:29:31 -0400 (Thu, 19 Mar 2009)
New Revision: 12619
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
api call for canceling and reseting trigger events
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-03-19 20:01:47 UTC (rev 12618)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-03-19 20:29:31 UTC (rev 12619)
@@ -3220,5 +3220,62 @@
}
+__PACKAGE__->register_method (
+ method => 'update_events',
+ api_name => 'open-ils.actor.user.event.cancel.batch',
+ stream => 1,
+);
+__PACKAGE__->register_method (
+ method => 'update_events',
+ api_name => 'open-ils.actor.user.event.reset.batch',
+ stream => 1,
+);
+
+sub update_events {
+ my($self, $conn, $auth, $event_ids) = @_;
+ my $e = new_editor(xact => 1, authtoken => $auth);
+ return $e->die_event unless $e->checkauth;
+
+ my $x = 1;
+ for my $id (@$event_ids) {
+
+ # do a little dance to determine what user we are ultimately affecting
+ my $event =
+ my $def = $e->retrieve_action_trigger_event([
+ $id,
+ { flesh => 2,
+ flesh_fields => {atev => ['event_def'], atevdef => ['hook']}
+ }
+ ]) or return $e->die_event;
+
+ my $user_id;
+ if($event->event_def->hook->core_type eq 'circ') {
+ $user_id = $e->retrieve_action_circulation($event->target)->usr;
+ } elsif($event->event_def->hook->core_type eq 'ahr') {
+ $user_id = $e->retrieve_action_hold_request($event->target)->usr;
+ } else {
+ return 0;
+ }
+
+ my $user = $e->retrieve_actor_user($user_id);
+ return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
+
+ if($self->api_name =~ /cancel/) {
+ $event->state('invalid');
+ } elsif($self->api_name =~ /reset/) {
+ $event->clear_start_time;
+ $event->clear_update_time;
+ $event->state('pending');
+ }
+
+ $e->update_action_trigger_event($event) or return $e->die_event;
+ $conn->respond({maximum => scalar(@$event_ids), progress => $x++});
+ }
+
+ $e->commit;
+ return {complete => 1};
+}
+
+
1;
More information about the open-ils-commits
mailing list