PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.2.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.2.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / WorkFlow / WorkFlow.php

WorkFlow.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.2.1, at includes/Core/WorkFlow/WorkFlow.php

559 lines 23.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\WorkFlow;
4
5 use BitCode\BitForm\Admin\Form\AdminFormManager;
6 use BitCode\BitForm\Core\Database\FormEntryMetaModel;
7 use BitCode\BitForm\Core\Database\WorkFlowModel;
8 use BitCode\BitForm\Core\Integration\IntegrationHandler;
9 use BitCode\BitForm\Core\Integration\Integrations;
10 use BitCode\BitForm\Core\Util\MailNotifier;
11
12 final class WorkFlow
13 {
14 private static $_formID;
15 private static $_workFlowModel;
16 private $_actions;
17
18 private $_user_details;
19
20 public function __construct($formID, $user_details = null)
21 {
22 static::$_formID = $formID;
23 static::$_workFlowModel = new WorkFlowModel();
24 $this->_user_details = $user_details;
25 $this->_actions = new Actions($formID);
26 }
27
28 public function getWorkFlow($workFlowRun, $workFlowType, $workFlowIds = null, $orderColumn = 'id', $workFlowStatus = 1, $workFlowCategories = null)
29 {
30 if (null === $workFlowIds) {
31 $condition = [
32 'form_id' => static::$_formID,
33 ];
34 } else {
35 $condition = [
36 'id' => $workFlowIds,
37 ];
38 }
39 if (!empty($workFlowRun)) {
40 $condition = \array_merge(
41 $condition,
42 [
43 'workflow_run' => $workFlowRun,
44 ]
45 );
46 }
47 if (!empty($workFlowType)) {
48 if (!is_array($workFlowType)) {
49 $workFlowType = [$workFlowType];
50 }
51 $condition = \array_merge(
52 $condition,
53 [
54 'workflow_type' => $workFlowType,
55 ]
56 );
57 }
58 if (!empty($workFlowStatus)) {
59 $condition = \array_merge(
60 $condition,
61 [
62 'workflow_status' => $workFlowStatus,
63 ]
64 );
65 }
66 // Free/Pro separation: Free only ever processes non-advanced rows. Pro runs its own
67 // pass that fetches category 'advanced' (see bitform_process_advanced_workflows).
68 // This single chokepoint excludes advanced rows from every execute* lifecycle method.
69 $categories = null === $workFlowCategories
70 ? apply_filters('bitform_workflow_categories_to_process', ['classic', 'basic'])
71 : $workFlowCategories;
72 $condition = \array_merge(
73 $condition,
74 [
75 'workflow_category' => $categories,
76 ]
77 );
78 $workFlows = static::$_workFlowModel->get(
79 [
80 'id',
81 'workflow_type',
82 'workflow_run',
83 'workflow_behaviour',
84 'workflow_condition',
85 'workflow_info',
86 'workflow_category',
87 'workflow_name',
88 'workflow_order',
89 'workflow_status',
90 ],
91 $condition,
92 null,
93 null,
94 $orderColumn,
95 'desc'
96 );
97 if (empty($workFlows) || is_wp_error($workFlows)) {
98 return [];
99 }
100
101 return $workFlows;
102 }
103
104 public function executeOnLoad($workFlowRun, $fields)
105 {
106 $workFlows = $this->getWorkFlow(['create_edit', $workFlowRun], ['always', 'onload'], null, 'workflow_order');
107 if (empty($workFlows) || is_wp_error($workFlows)) {
108 // No classic/basic onload rows. Pro may still apply advanced field show/hide; no-op when inactive.
109 return apply_filters('bitform_process_advanced_workflows_onload', [], $workFlowRun, $fields, static::$_formID);
110 }
111 $workFlows = array_reverse($workFlows);
112 $fieldData = Helper::getFieldData($fields);
113 $data = $this->runLoadWorkflowFields($workFlows, $fields, $fieldData);
114 $fields = $data[0];
115
116 $workFlowReturnable = ['fields' => $fields];
117 // Pro advanced pass (field show/hide on load). No-op when no listener (Pro inactive).
118 $workFlowReturnable = apply_filters('bitform_process_advanced_workflows_onload', $workFlowReturnable, $workFlowRun, $fields, static::$_formID);
119 return $workFlowReturnable;
120 }
121
122 /**
123 * Apply onload field-property actions for a set of workflow rows. Extracted so Pro can reuse it
124 * for category 'advanced' rows (excluded from Free's getWorkFlow).
125 *
126 * @return array [$fields, $fieldData]
127 */
128 public function runLoadWorkflowFields(array $workFlows, $fields, $fieldData)
129 {
130 foreach ($workFlows as $workFlow) {
131 $conditions = json_decode($workFlow->workflow_condition);
132 $conditionBehaviour = $workFlow->workflow_behaviour;
133 if ('cond' === $conditionBehaviour) {
134 foreach ($conditions as $condition) {
135 $type = $condition->cond_type;
136 if (!empty($condition->actions->fields)) {
137 $conditionStatus = false;
138
139 if (!empty($condition->logics)) {
140 $logics = $condition->logics;
141 $fieldData = Helper::smartFldMargeFormFld($logics, $fieldData);
142 $conditionalLogic = new ConditionalLogic($logics, $fieldData);
143 $conditionStatus = $conditionalLogic->getConditionStatus();
144 }
145 if (($conditionStatus && in_array($type, ['if', 'else-if']) || 'else' === $type)) {
146 $data = $this->_actions->setFieldProperty($condition->actions->fields, $fieldData, $fields);
147 $fields = $data[0];
148 $fieldData = $data[1];
149 break;
150 }
151 }
152 }
153 } elseif ('always' === $conditionBehaviour) {
154 if (!empty($conditions[0]->actions->fields)) {
155 $data = $this->_actions->setFieldProperty($conditions[0]->actions->fields, $fieldData, $fields);
156 $fields = $data[0];
157 $fieldData = $data[1];
158 }
159 }
160 }
161 return [$fields, $fieldData];
162 }
163
164 public function executeOnUserInput($workFlowRun)
165 {
166 $workFlows = $this->getWorkFlow(['create_edit', $workFlowRun], ['always', 'oninput'], null, 'workflow_order');
167 $workFlowReturnable = [];
168 if (empty($workFlows) || is_wp_error($workFlows)) {
169 return apply_filters('bitform_advanced_oninput_conditions', $workFlowReturnable, $workFlowRun, static::$_formID);
170 }
171 $onUserInputRun = [];
172 foreach ($workFlows as $index => $value) {
173 $conditions = json_decode($value->workflow_condition);
174 $onUserInputRun['event_type'] = 'on_input';
175 $onUserInputRun['conditions'] = $conditions;
176
177 $workFlowReturnable['onfield_input_conditions'][$index] = $onUserInputRun;
178 }
179 // Pro advanced pass (appends advanced on-input conditions). No-op when no listener.
180 $workFlowReturnable = apply_filters('bitform_advanced_oninput_conditions', $workFlowReturnable, $workFlowRun, static::$_formID);
181 return $workFlowReturnable;
182 }
183
184 public function executeOnValidate($workFlowRun, $fieldData, $fieldValue)
185 {
186 $workFlows = $this->getWorkFlow(['create_edit', $workFlowRun], 'onvalidate', null, 'workflow_order');
187 $workFlowReturnable = [];
188 if (!empty($workFlows) && !is_wp_error($workFlows)) {
189 $workFlowReturnable = $this->runValidateWorkflow($workFlows, $workFlowReturnable, $fieldData, $fieldValue);
190 }
191 // Pro advanced pass (advanced validation routing). No-op when no listener.
192 $workFlowReturnable = apply_filters('bitform_process_advanced_workflows_onvalidate', $workFlowReturnable, $workFlowRun, $fieldData, $fieldValue, static::$_formID);
193 return $workFlowReturnable;
194 }
195
196 /**
197 * Evaluate onvalidate rows and resolve the failure (validation) message. Extracted so Pro can
198 * reuse it for category 'advanced' rows.
199 *
200 * @return array $workFlowReturnable
201 */
202 public function runValidateWorkflow(array $workFlows, $workFlowReturnable, $fieldData, $fieldValue)
203 {
204 foreach ($workFlows as $workFlow) {
205 $conditions = json_decode($workFlow->workflow_condition);
206 $conditionBehaviour = $workFlow->workflow_behaviour;
207 if ('cond' === $conditionBehaviour) {
208 foreach ($conditions as $condition) {
209 $type = $condition->cond_type;
210 if (!empty($condition->actions->failure)) {
211 $validateMsg = $condition->actions->failure;
212 } else {
213 $validateMsg = '{"id":"0"}';
214 }
215 $conditionStatus = false;
216 if (!empty($condition->logics)) {
217 $logics = $condition->logics;
218 $fieldData = Helper::smartFldMargeFormFld($logics, $fieldData);
219 $conditionalLogic = new ConditionalLogic($logics, $fieldData);
220 $conditionStatus = $conditionalLogic->getConditionStatus();
221 }
222 if (($conditionStatus && in_array($type, ['if', 'else-if'])) || 'else' === $type) {
223 $workFlowReturnable = $this->_actions->confirmationMessage($workFlowReturnable, $validateMsg, $fieldValue);
224 if (empty($workFlowReturnable)) {
225 $workFlowReturnable['message'] = '<p>Something error in Form Validation</p>';
226 }
227 break;
228 }
229 }
230 }
231 }
232 return $workFlowReturnable;
233 }
234
235 public function isExistDoubleOptin($data)
236 {
237 $data['integrationRun'] = true;
238 if (has_action('bitform_double_optin_confirmation')) {
239 $activeDoubleOpt = (new IntegrationHandler(static::$_formID))->getAllIntegration('double-opt-in', 'double-opt-in', 1);
240
241 if (!is_wp_error($activeDoubleOpt) && count($activeDoubleOpt) > 0) {
242 $dplOptinDetails = json_decode($activeDoubleOpt[0]->integration_details);
243 if (isset($dplOptinDetails->disable_loggin_user) && !is_user_logged_in() || !isset($dplOptinDetails->disable_loggin_user)) {
244 $data['integrationRun'] = false;
245 $data['integrationDetails'] = $activeDoubleOpt[0];
246 $data['dflt_template'] = isset($dplOptinDetails->dflt_temp) ? true : false;
247 }
248 }
249 }
250 return $data;
251 }
252
253 public function executeOnSubmit($workFlowRun, $fields, $fieldValue, $entryID, $logID, $workflowsIds = null)
254 {
255 $workFlows = $this->getWorkFlow(['create_edit', $workFlowRun], ['onsubmit'], $workflowsIds, 'workflow_order');
256 $workFlowReturnable = [];
257 $workFlowReturnable = $this->isExistDoubleOptin($workFlowReturnable);
258 if (empty($workFlows) || is_wp_error($workFlows)) {
259 $defaultConfimation = Helper::setDefaultSubmitConfirmation('successMsg', $fieldValue, static::$_formID, 0, $workFlowRun);
260 if (empty($defaultConfimation['confirmation'])) {
261 $workFlowReturnable['message'] = 'edit' !== $workFlowRun ? __('Form Submitted Successfully', 'bit-form')
262 : __('Entry Updated Successfully', 'bit-form');
263 $workFlowReturnable['msg_id'] = 0;
264 } else {
265 $workFlowReturnable['message'] = $defaultConfimation['confirmation'];
266 $workFlowReturnable['msg_id'] = $defaultConfimation['msg_id'];
267 }
268 if (!empty($defaultConfimation['afterSubmit'])) {
269 $workFlowReturnable['afterSubmit'] = $defaultConfimation['afterSubmit'];
270 }
271 if (!empty($defaultConfimation['msg_duration'])) {
272 $workFlowReturnable['msg_duration'] = $defaultConfimation['msg_duration'];
273 }
274 $workFlowReturnable['dflt_message'] = true;
275 $defaultConfimation = Helper::setDefaultSubmitConfirmation('redirectPage', $fieldValue, static::$_formID, 0, $workFlowRun);
276
277 $workFlowReturnable['redirectPage'] = $defaultConfimation['confirmation'];
278 $isCronOK = !defined('DOING_CRON') && wp_doing_ajax() && (!defined('DISABLE_WP_CRON') || (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON));
279 if ($isCronOK) {
280 $gmt_time = microtime(true);
281 $lock = get_transient('doing_cron');
282 if ($lock > $gmt_time + 10 * MINUTE_IN_SECONDS) {
283 $lock = 0;
284 }
285 if ($lock + WP_CRON_LOCK_TIMEOUT > $gmt_time) {
286 $isCronOK = false;
287 }
288 }
289 $data = [
290 'mail' => Helper::getDefaultMailNotifications(static::$_formID, $workFlowRun),
291 'integrations' => Helper::getDefaultIntegrations(static::$_formID, $workFlowRun),
292 'entryID' => $entryID,
293 'logID' => $logID,
294 'formID' => static::$_formID,
295 ];
296 $workFlowReturnable['triggerData'] = $data;
297 $workFlowReturnable['cron'] = $isCronOK;
298 if (!$isCronOK) {
299 $workFlowReturnable['cronNotOk'] = [$entryID, $logID];
300 }
301 // Pro advanced pass: even with no classic/basic rows, advanced (Pro) rows may add confirmation/redirect/mail/integration.
302 $workFlowReturnable = apply_filters('bitform_process_advanced_workflows', $workFlowReturnable, $workFlowRun, $fields, $fieldValue, $entryID, $logID, static::$_formID);
303 return $this->suppressFallbackMessageOnRedirect($workFlowReturnable);
304 }
305
306 $fieldData = Helper::getFieldData($fields);
307
308 $isCronOK = !defined('DOING_CRON') && wp_doing_ajax() && (!defined('DISABLE_WP_CRON') || (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON));
309 if ($isCronOK) {
310 // From wp spawn_cron()
311 $gmt_time = microtime(true);
312 $lock = get_transient('doing_cron');
313 if ($lock > $gmt_time + 10 * MINUTE_IN_SECONDS) {
314 $lock = 0;
315 }
316 if ($lock + WP_CRON_LOCK_TIMEOUT > $gmt_time) {
317 $isCronOK = false;
318 }
319 }
320
321 $onFormSuccessActionDefault = [
322 'workFlowReturnable' => $workFlowReturnable,
323 'mailData' => [],
324 'dblOptin' => [],
325 'integrationsToExc' => [],
326 'isWebHookQueued' => false,
327 ];
328
329 $onFormSuccessActionDefault = $this->runSubmitWorkflowActions($workFlows, $onFormSuccessActionDefault, $fieldData, $fieldValue, $entryID);
330 if (isset($onFormSuccessActionDefault['workFlowReturnable']['fields'])) {
331 $fieldValue = $onFormSuccessActionDefault['workFlowReturnable']['fields'];
332 }
333 $workFlowReturnable = $onFormSuccessActionDefault['workFlowReturnable'];
334 $integrationsToExc = $onFormSuccessActionDefault['integrationsToExc'];
335 if (empty($workFlowReturnable['message'])) {
336 $defaultConfimation = Helper::setDefaultSubmitConfirmation('successMsg', $fieldValue, static::$_formID, $logID, $workFlowRun);
337 $workFlowReturnable['message'] = $defaultConfimation['confirmation'];
338 $workFlowReturnable['msg_id'] = $defaultConfimation['msg_id'];
339
340 if (empty($defaultConfimation['confirmation'])) {
341 $workFlowReturnable['message'] = 'edit' !== $workFlowRun ? __('Form Submitted Successfully', 'bit-form')
342 : __('Entry Updated Successfully', 'bit-form');
343 $workFlowReturnable['msg_id'] = 0;
344 }
345 if (!empty($defaultConfimation['afterSubmit'])) {
346 $workFlowReturnable['afterSubmit'] = $defaultConfimation['afterSubmit'];
347 }
348 if (!empty($defaultConfimation['msg_duration'])) {
349 $workFlowReturnable['msg_duration'] = $defaultConfimation['msg_duration'];
350 }
351 $workFlowReturnable['dflt_message'] = true;
352 }
353 if (empty($workFlowReturnable['redirectPage'])) {
354 $defaultConfimation = Helper::setDefaultSubmitConfirmation('redirectPage', $fieldValue, static::$_formID, $logID, $workFlowRun);
355
356 $workFlowReturnable['redirectPage'] = $defaultConfimation['confirmation'];
357 }
358 // Default-execute every enabled email/integration NOT gated by a workflow (classic/basic/advanced).
359 // getDefault* exclude ids referenced by workflows (Free filter) and advanced CL (Pro filter), so the
360 // workflow-queued actions above are not duplicated and gated actions are not run unconditionally.
361 $data = [
362 'mail' => array_merge($onFormSuccessActionDefault['mailData'], Helper::getDefaultMailNotifications(static::$_formID, $workFlowRun)),
363 'dblOptin' => $onFormSuccessActionDefault['dblOptin'],
364 'integrations' => array_merge($integrationsToExc, Helper::getDefaultIntegrations(static::$_formID, $workFlowRun)),
365 'entryID' => $entryID,
366 'logID' => $logID,
367 'formID' => static::$_formID,
368 ];
369 $workFlowReturnable['triggerData'] = $data;
370 if ($isCronOK) {
371 $workFlowReturnable['cron'] = true;
372 } else {
373 $workFlowReturnable['cron'] = false;
374 }
375 // }
376 // Pro advanced pass: queries category 'advanced' rows and merges/overrides confirmation, redirect, mail and integrations.
377 $workFlowReturnable = apply_filters('bitform_process_advanced_workflows', $workFlowReturnable, $workFlowRun, $fields, $fieldValue, $entryID, $logID, static::$_formID);
378 return $this->suppressFallbackMessageOnRedirect($workFlowReturnable);
379 }
380
381 /**
382 * When only a redirect is configured (no confirmation message), skip the hardcoded
383 * fallback message so the frontend redirects immediately instead of flashing it.
384 * Only the fallback ever has dflt_message with msg_id 0; configured messages always
385 * carry a DB msg_id. Message is blanked ('' not unset) so maybeSetCronForIntegration
386 * still forwards hidden_fields/msg_id, and dflt_message is kept so the WP-registration
387 * success-message override in FrontendFormManager still applies.
388 */
389 private function suppressFallbackMessageOnRedirect($workFlowReturnable)
390 {
391 if (
392 !empty($workFlowReturnable['dflt_message'])
393 && empty($workFlowReturnable['msg_id'])
394 && !empty($workFlowReturnable['redirectPage'])
395 ) {
396 $workFlowReturnable['message'] = '';
397 }
398 return $workFlowReturnable;
399 }
400
401 /**
402 * Evaluate a set of onsubmit workflow rows and accumulate their success actions.
403 * Extracted from executeOnSubmit so BitForm Pro can reuse the exact same evaluation/action
404 * pipeline for category 'advanced' rows (which Free's getWorkFlow excludes).
405 *
406 * @param array $workFlows rows from getWorkFlow()
407 * @param array $onFormSuccessActionDefault accumulator: workFlowReturnable, mailData, dblOptin, integrationsToExc, isWebHookQueued
408 * @param array $fieldData result of Helper::getFieldData($fields)
409 *
410 * @return array updated $onFormSuccessActionDefault (latest field values under ['workFlowReturnable']['fields'])
411 */
412 public function runSubmitWorkflowActions(array $workFlows, array $onFormSuccessActionDefault, $fieldData, $fieldValue, $entryID)
413 {
414 foreach ($workFlows as $workFlow) {
415 $conditions = json_decode($workFlow->workflow_condition);
416
417 $conditionBehaviour = $workFlow->workflow_behaviour;
418 if ('cond' === $conditionBehaviour) {
419 foreach ($conditions as $condition) {
420 $type = $condition->cond_type;
421 if (!empty($condition->actions)) {
422 $actions = $condition->actions;
423 $conditionStatus = false;
424 if (!empty($condition->logics)) {
425 $logics = $condition->logics;
426 $fieldData = Helper::smartFldMargeFormFld($logics, $fieldData);
427 $conditionalLogic = new ConditionalLogic($logics, $fieldData);
428 $conditionStatus = $conditionalLogic->getConditionStatus();
429 }
430 $conditionStatus = apply_filters('bitform_filter_workflow_condition_status', $conditionStatus, $condition, $fieldData, $this::$_formID);
431
432 if (($conditionStatus && in_array($type, ['if', 'else-if'])) || 'else' === $type) {
433 $fieldValue = $this->_actions->setOnSubmitSetFieldValue($actions->fields, $fieldValue);
434 $onFormSuccessActionDefault = $this->_actions->setOnFormSuccess($onFormSuccessActionDefault, $actions->success, $fieldValue, $entryID);
435 $onFormSuccessActionDefault['workFlowReturnable']['fields'] = $fieldValue;
436 break;
437 }
438 }
439 }
440 } elseif ('always' === $conditionBehaviour) {
441 $actions = $conditions[0]->actions;
442 $fieldValue = $this->_actions->setOnSubmitSetFieldValue($actions->fields, $fieldValue);
443 $onFormSuccessActionDefault = $this->_actions->setOnFormSuccess($onFormSuccessActionDefault, $actions->success, $fieldValue, $entryID);
444 $onFormSuccessActionDefault['workFlowReturnable']['fields'] = $fieldValue;
445 }
446 }
447 return $onFormSuccessActionDefault;
448 }
449
450 public function executeOnDelete(AdminFormManager $formManager, $formID, $deletedIds)
451 {
452 $workFlows = $this->getWorkFlow(['delete'], 'delete');
453 $workFlowReturnable = [];
454 if (empty($workFlows) || is_wp_error($workFlows) || empty($deletedIds)) {
455 return [];
456 }
457 if (!$formManager instanceof AdminFormManager) {
458 $formManager = new AdminFormManager($formID);
459 }
460 $returnableEntries = $deletedIds;
461 $formFields = $formManager->getFieldLabel();
462 $entryMeta = new FormEntryMetaModel();
463 $entries = $entryMeta->getEntryMeta(
464 $formFields,
465 $deletedIds
466 );
467 if (is_wp_error($entries) || empty($entries['entries'])) {
468 return $entries;
469 }
470 foreach ($entries['entries'] as $entry) {
471 $fieldValue = (array) $entry;
472 unset($fieldValue['entry_id']);
473 $fields = $formManager->getFormContentWithValue($fieldValue)->fields;
474 $fieldData = Helper::getFieldData($fields);
475
476 foreach ($workFlows as $workFlow) {
477 $workFlowBlock = json_decode($workFlow->workflow_condition);
478 // $conditions = $workFlowBlock->logics;
479 // $actions = $workFlowBlock->actions;
480 $conditionBehaviour = $workFlow->workflow_behaviour;
481
482 if ('cond' === $conditionBehaviour) {
483 foreach ($workFlowBlock as $condition) {
484 $actions = $condition->actions;
485 $type = $condition->cond_type;
486 $logics = $condition->logics;
487 $fieldData = Helper::smartFldMargeFormFld($logics, $fieldData);
488 $conditionalLogic = new ConditionalLogic($logics, $fieldData);
489 $conditionStatus = $conditionalLogic->getConditionStatus();
490
491 $conditionStatus = apply_filters('bitform_filter_workflow_condition_status', $conditionStatus, $condition, $fieldData, $this::$_formID);
492
493 if (($conditionStatus && in_array($type, ['if', 'else-if'])) || 'else' === $type) {
494 $isExists = \array_search($entry->entry_id, $returnableEntries);
495 if (!empty($actions->avoid_delete) && false !== $isExists) {
496 unset($returnableEntries[$isExists]);
497 $returnableEntries = array_values($returnableEntries);
498 } elseif (false === $isExists) {
499 $returnableEntries[] = $entry->entry_id;
500 }
501 if (!empty($actions->success)) {
502 foreach ($actions->success as $successActionDetail) {
503 switch ($successActionDetail->type) {
504 case 'webHooks':
505 if (!empty($successActionDetail->details->id)) {
506 $webHooks = $successActionDetail->details->id;
507 Integrations::executeIntegrations($webHooks, $fieldValue, static::$_formID);
508 }
509 break;
510 case 'mailNotify':
511 if (!empty($successActionDetail->details->id)) {
512 MailNotifier::notify($successActionDetail->details, static::$_formID, $fieldValue, $entry->entry_id);
513 }
514 break;
515 default:
516 break;
517 }
518 }
519 }
520 break;
521 }
522 }
523 } elseif ('always' === $conditionBehaviour) {
524 $actions = $workFlowBlock[0]->actions;
525 $isExists = \array_search($entry->entry_id, $returnableEntries);
526 if (!empty($actions->avoid_delete) && false !== $isExists) {
527 unset($returnableEntries[$isExists]);
528 $returnableEntries = array_values($returnableEntries);
529 } elseif (false === $isExists) {
530 $returnableEntries[] = $entry->entry_id;
531 }
532 if (!empty($actions->success)) {
533 foreach ($actions->success as $successActionDetail) {
534 switch ($successActionDetail->type) {
535 case 'webHooks':
536 if (!empty($successActionDetail->details->id)) {
537 $webHooks = $successActionDetail->details->id;
538 Integrations::executeIntegrations($webHooks, $fieldValue, static::$_formID);
539 }
540 break;
541 case 'mailNotify':
542 if (!empty($successActionDetail->details->id)) {
543 MailNotifier::notify($successActionDetail->details, static::$_formID, $fieldValue, $entry->entry_id);
544 }
545 break;
546 default:
547 break;
548 }
549 }
550 }
551 }
552 }
553 }
554 // }
555 $workFlowReturnable['entries'] = array_values($returnableEntries);
556 return $workFlowReturnable;
557 }
558 }
559