PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Controllers/Automations/Condition.php +85 -0 10.1.2 → 11.1.0 View file →
@@ -1,0 +1,85 @@
1 +<?php
2 +
3 +namespace AcyMailing\Controllers\Automations;
4 +
5 +use AcyMailing\Classes\AutomationClass;
6 +use AcyMailing\Classes\ConditionClass;
7 +use AcyMailing\Classes\StepClass;
8 +use AcyMailing\Helpers\WorkflowHelper;
9 +
10 +trait Condition
11 +{
12 + public function condition(): void
13 + {
14 + if (!acym_level(ACYM_ENTERPRISE)) {
15 + acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
16 + }
17 +
18 + }
19 +
20 + private function getSaveConditions(bool $isMassAction = false): array
21 + {
22 + $automationID = acym_getVar('int', 'id');
23 + $conditionId = acym_getVar('int', 'conditionId');
24 + $condition = acym_getVar('array', 'acym_condition', []);
25 + $conditionClass = new ConditionClass();
26 +
27 + $stepAutomationId = acym_getVar('int', 'stepAutomationId');
28 +
29 + if (!empty($conditionId)) {
30 + $condition['id'] = $conditionId;
31 + }
32 +
33 + $condition['conditions']['type_condition'] = acym_getVar('string', 'type_condition');
34 +
35 + if ($isMassAction) {
36 + $massAction = acym_getVar('array', 'massAction', [], 'SESSION');
37 + $massAction['conditions'] = $condition['conditions'];
38 + acym_setSession('massAction', $massAction);
39 +
40 + return [];
41 + }
42 +
43 + $condition['conditions'] = json_encode($condition['conditions']);
44 +
45 + $condition['step_id'] = $stepAutomationId;
46 +
47 + foreach ($condition as $column => $value) {
48 + acym_secureDBColumn($column);
49 + }
50 +
51 + //We need an object to save it so we make a object
52 + $condition = (object)$condition;
53 +
54 + $condition->id = $conditionClass->save($condition);
55 +
56 + return [
57 + 'automationId' => $automationID,
58 + 'stepId' => $stepAutomationId,
59 + 'conditionId' => $condition->id,
60 + ];
61 + }
62 +
63 + public function saveExitConditions(): void
64 + {
65 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
66 +
67 + $this->getSaveConditions();
68 +
69 + acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
70 +
71 + $this->listing();
72 + }
73 +
74 + public function saveConditions(): void
75 + {
76 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
77 +
78 + $ids = $this->getSaveConditions();
79 +
80 + acym_setVar('id', $ids['automationId']);
81 + acym_setVar('stepId', $ids['stepId']);
82 + acym_setVar('conditionId', $ids['conditionId']);
83 + $this->action();
84 + }
85 +}