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 -137 10.0.1 → 11.1.1 View file →
@@ -1,137 +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()
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($isMassAction = false)
22 - {
23 - if ($isMassAction) {
24 - acym_session();
25 - }
26 -
27 - $automationId = acym_getVar('int', 'id');
28 - $automation = acym_getVar('array', 'automation');
29 - $automationClass = new AutomationClass();
30 -
31 - $stepAutomationId = acym_getVar('int', 'stepAutomationId');
32 - $stepAutomation = acym_getVar('array', 'stepAutomation');
33 - $typeTrigger = acym_getVar('string', 'type_trigger');
34 - $stepClass = new StepClass();
35 -
36 - if (!empty($automationId)) {
37 - $automation['id'] = $automationId;
38 - }
39 -
40 - if (!empty($stepAutomationId)) {
41 - $stepAutomation['id'] = $stepAutomationId;
42 - $conditionClass = new ConditionClass();
43 - $actionClass = new ActionClass();
44 - $condition = $conditionClass->getOneByStepId($stepAutomationId);
45 - $step = $stepClass->getOneById($stepAutomationId);
46 -
47 - $triggerChanged = $typeTrigger === 'classic' && json_decode($step->triggers)->type_trigger === 'user';
48 - if ($triggerChanged && !empty($condition)) {
49 - $action = $actionClass->getOneByConditionId($condition->id);
50 - if (json_decode($condition->conditions)->type_condition === 'user') {
51 - $condition->conditions = null;
52 - $conditionClass->save($condition);
53 - }
54 - if (!empty($action->filters) && json_decode($action->filters)->type_filter === 'user') {
55 - $action->filters = null;
56 - $actionClass->save($action);
57 - }
58 - }
59 - }
60 -
61 - if (empty($automation['admin'])) {
62 - if (empty($automation['name'])) return false;
63 -
64 - $automation['admin'] = 0;
65 - }
66 -
67 - if (empty($stepAutomation['triggers'][$typeTrigger])) {
68 - acym_enqueueMessage(acym_translation('ACYM_PLEASE_SELECT_ONE_TRIGGER'), 'error');
69 -
70 - $this->info();
71 -
72 - return false;
73 - }
74 -
75 - $stepAutomation['triggers'][$typeTrigger]['type_trigger'] = $typeTrigger;
76 - $stepAutomation['triggers'] = json_encode($stepAutomation['triggers'][$typeTrigger]);
77 -
78 - $stepAutomation['automation_id'] = $automationId;
79 -
80 - foreach ($automation as $column => $value) {
81 - acym_secureDBColumn($column);
82 - }
83 -
84 - foreach ($stepAutomation as $stepColumn => $stepValue) {
85 - acym_secureDBColumn($stepColumn);
86 - }
87 -
88 - $automation = (object)$automation;
89 - $stepAutomation = (object)$stepAutomation;
90 -
91 - $automation->id = $automationClass->save($automation);
92 - $stepAutomation->automation_id = $automation->id;
93 - $stepAutomation->id = $stepClass->save($stepAutomation);
94 -
95 - $returnIds = [
96 - "automationId" => $automation->id,
97 - "stepId" => $stepAutomation->id,
98 - "typeTrigger" => $typeTrigger,
99 - ];
100 -
101 - if ($isMassAction) {
102 - return true;
103 - } elseif (!empty($returnIds['automationId']) && !empty($returnIds['stepId'])) {
104 - return $returnIds;
105 - } else {
106 - return false;
107 - }
108 - }
109 -
110 - public function saveExitInfo()
111 - {
112 - $ids = $this->_saveInfos();
113 -
114 - if (empty($ids)) {
115 - return;
116 - }
117 -
118 - acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
119 -
120 - acym_setVar('id', $ids['automationId']);
121 - acym_setVar('stepId', $ids['stepId']);
122 - $this->listing();
123 - }
124 -
125 - public function saveInfo()
126 - {
127 - $ids = $this->_saveInfos();
128 -
129 - if (empty($ids)) {
130 - return;
131 - }
132 -
133 - acym_setVar('id', $ids['automationId']);
134 - acym_setVar('stepId', $ids['stepId']);
135 - $this->condition();
136 - }
137 -}