diff --git a/app/Model/Event.php b/app/Model/Event.php index fe4347265..90c608d29 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -499,6 +499,24 @@ class Event extends AppModel $this->data['Event']['uuid'] = CakeText::uuid(); } $this->__beforeSaveData = $this->data['Event']; + + $trigger_id = 'event-before-save'; + if ($this->isTriggerCallable($trigger_id)) { + $event = $this->data; + $workflowErrors = []; + $logging = [ + 'model' => 'Event', + 'action' => 'add', + 'id' => 0, + 'message' => __('The workflow `%s` prevented the saving of event (%s)', $trigger_id, $event['Event']['uuid']), + ]; + $triggerData = $event; + $workflowSuccess = $this->executeTrigger($trigger_id, $triggerData, $workflowErrors, $logging); + if (!$workflowSuccess) { + return false; + } + } + return true; } diff --git a/app/Model/WorkflowModules/trigger/Module_event_before_save.php b/app/Model/WorkflowModules/trigger/Module_event_before_save.php new file mode 100644 index 000000000..aac950e0e --- /dev/null +++ b/app/Model/WorkflowModules/trigger/Module_event_before_save.php @@ -0,0 +1,22 @@ +trigger_overhead_message = __('This trigger is called each time an Event or Attribute is about to be saved. This means that when a large quantity of Attributes are being saved (e.g. Feed pulling or synchronisation), the workflow will be run for as many time as there are Attributes.'); + } +}