LP1207533 setting context_user and context_library
authorJason Etheridge <jason@EquinoxInitiative.org>
Mon, 17 Aug 2020 03:35:02 +0000 (23:35 -0400)
committerJason Etheridge <jason@EquinoxInitiative.org>
Tue, 1 Sep 2020 19:24:35 +0000 (15:24 -0400)
on action_trigger.event when building the environment

Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm

index 4291eeb..91cd00e 100644 (file)
@@ -520,6 +520,24 @@ sub build_environment {
                 $self->_object_by_path( $self->event->event_def, undef, [qw/usr_message sending_lib/], ['owner'] );
             }
         }
+
+        if ($self->event->event_def->context_usr_path) {
+            my @usr_path = split(/\./, $self->event->event_def->context_usr_path);
+            $self->_object_by_path( $self->target, undef, [qw/context usr/], \@usr_path );
+
+            if ($self->event->event_def->context_library_path) {
+                my @library_path = split(/\./, $self->event->event_def->context_library_path);
+                $self->_object_by_path( $self->target, undef, [qw/context org/], \@library_path );
+            } else {
+                $self->_object_by_path( $self->event->event_def, undef, [qw/context org/], ['owner'] );
+            }
+            $self->update_state(
+                $self->event->state, {
+                    'context_user' => $self->environment->{context}->{usr}->id,
+                    'context_library' => $self->environment->{context}->{org}->id
+                }
+            );
+        }
     
         $self->environment->{complete} = 1;
     } otherwise {