From: Bill Erickson Date: Tue, 7 Aug 2012 20:28:33 +0000 (-0400) Subject: Added is_event check to AppUtils X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b5a466cc90da7159fe0108df88d7af0dbec8ec9c;p=evergreen%2Fequinox.git Added is_event check to AppUtils Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 2529d6b6a8..a3a1b08fdf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -138,10 +138,22 @@ sub rollback_db_session { # returns the event code otherwise sub event_code { my( $self, $evt ) = @_; - return $evt->{ilsevent} if( ref($evt) eq 'HASH' and defined($evt->{ilsevent})) ; + return $evt->{ilsevent} if $self->is_event($evt); return undef; } +# some events, in particular auto-generated events, don't have an +# ilsevent key. treat hashes with a 'textcode' key as events. +sub is_event { + my ($self, $evt) = @_; + return ( + ref($evt) eq 'HASH' and ( + defined $evt->{ilsevent} or + defined $evt->{textcode} + ) + ); +} + # --------------------------------------------------------------------------- # Checks to see if a user is logged in. Returns the user record on success, # throws an exception on error.