PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
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/Info.php +0 -133 10.10.2 → 11.1.1 View file →
@@ -1,133 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Automations;
4 -
5 -use AcyMailing\Classes\ActionClass;
6 -use AcyMailing\Classes\AutomationClass;
7 -use AcyMailing\Classes\ConditionClass;
8 -use AcyMailing\Classes\StepClass;
9 -use AcyMailing\Helpers\WorkflowHelper;
10 -
11 -trait Info
12 -{
13 - public function info(): void
14 - {
15 - if (!acym_level(ACYM_ENTERPRISE)) {
16 - acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
17 - }
18 -
19 - }
20 -
21 - private function saveInfos(): array
22 - {
23 - $automationId = acym_getVar('int', 'id');
24 - $automation = acym_getVar('array', 'automation');
25 - $automationClass = new AutomationClass();
26 -
27 - $stepAutomationId = acym_getVar('int', 'stepAutomationId');
28 - $stepAutomation = acym_getVar('array', 'stepAutomation');
29 - $typeTrigger = acym_getVar('string', 'type_trigger');
30 - $stepClass = new StepClass();
31 -
32 - if (!empty($automationId)) {
33 - $automation['id'] = $automationId;
34 - }
35 -
36 - if (!empty($stepAutomationId)) {
37 - $stepAutomation['id'] = $stepAutomationId;
38 - $conditionClass = new ConditionClass();
39 - $actionClass = new ActionClass();
40 - $condition = $conditionClass->getOneByStepId($stepAutomationId);
41 - $step = $stepClass->getOneById($stepAutomationId);
42 -
43 - $triggerChanged = $typeTrigger === 'classic' && json_decode($step->triggers)->type_trigger === 'user';
44 - if ($triggerChanged && !empty($condition)) {
45 - $action = $actionClass->getOneByConditionId($condition->id);
46 - if (json_decode($condition->conditions)->type_condition === 'user') {
47 - $condition->conditions = null;
48 - $conditionClass->save($condition);
49 - }
50 - if (!empty($action->filters) && json_decode($action->filters)->type_filter === 'user') {
51 - $action->filters = null;
52 - $actionClass->save($action);
53 - }
54 - }
55 - }
56 -
57 - if (empty($automation['admin'])) {
58 - if (empty($automation['name'])) {
59 - return [];
60 - }
61 -
62 - $automation['admin'] = 0;
63 - }
64 -
65 - if (empty($stepAutomation['triggers'][$typeTrigger])) {
66 - acym_enqueueMessage(acym_translation('ACYM_PLEASE_SELECT_ONE_TRIGGER'), 'error');
67 -
68 - $this->info();
69 -
70 - return [];
71 - }
72 -
73 - $stepAutomation['triggers'][$typeTrigger]['type_trigger'] = $typeTrigger;
74 - $stepAutomation['triggers'] = json_encode($stepAutomation['triggers'][$typeTrigger]);
75 -
76 - $stepAutomation['automation_id'] = $automationId;
77 -
78 - foreach ($automation as $column => $value) {
79 - acym_secureDBColumn($column);
80 - }
81 -
82 - foreach ($stepAutomation as $stepColumn => $stepValue) {
83 - acym_secureDBColumn($stepColumn);
84 - }
85 -
86 - $automation = (object)$automation;
87 - $stepAutomation = (object)$stepAutomation;
88 -
89 - $automation->id = $automationClass->save($automation);
90 - $stepAutomation->automation_id = $automation->id;
91 - $stepAutomation->id = $stepClass->save($stepAutomation);
92 -
93 - $returnIds = [
94 - 'automationId' => $automation->id,
95 - 'stepId' => $stepAutomation->id,
96 - 'typeTrigger' => $typeTrigger,
97 - ];
98 -
99 - if (!empty($returnIds['automationId']) && !empty($returnIds['stepId'])) {
100 - return $returnIds;
101 - } else {
102 - return [];
103 - }
104 - }
105 -
106 - public function saveExitInfo(): void
107 - {
108 - $ids = $this->saveInfos();
109 -
110 - if (empty($ids)) {
111 - return;
112 - }
113 -
114 - acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'));
115 -
116 - acym_setVar('id', $ids['automationId']);
117 - acym_setVar('stepId', $ids['stepId']);
118 - $this->listing();
119 - }
120 -
121 - public function saveInfo(): void
122 - {
123 - $ids = $this->saveInfos();
124 -
125 - if (empty($ids)) {
126 - return;
127 - }
128 -
129 - acym_setVar('id', $ids['automationId']);
130 - acym_setVar('stepId', $ids['stepId']);
131 - $this->condition();
132 - }
133 -}