PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.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
acymailing / back / Controllers / Automations / Action.php

Action.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Controllers/Automations/Action.php

128 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\MailClass;
9 use AcyMailing\Classes\StepClass;
10 use AcyMailing\Classes\TagClass;
11 use AcyMailing\Helpers\WorkflowHelper;
12
13 trait Action
14 {
15 public function action()
16 {
17
18 if (!acym_level(ACYM_ENTERPRISE)) {
19 acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
20 }
21 }
22
23 private function _saveActions($isMassAction = false)
24 {
25 if ($isMassAction) {
26 acym_session();
27 }
28
29 $automationID = acym_getVar('int', 'id');
30 $actionId = acym_getVar('int', 'actionId');
31 $action = acym_getVar('array', 'acym_action');
32 $actionClass = new ActionClass();
33 $stepAutomationId = acym_getVar('int', 'stepAutomationId');
34 $conditionId = acym_getVar('int', 'conditionId');
35
36 if ((!empty($conditionId))) {
37 $action['condition_id'] = $conditionId;
38 }
39
40 if (!empty($actionId)) {
41 $action['id'] = $actionId;
42 }
43
44 if (empty($action['actions'])) {
45 $action['actions'] = [];
46 }
47
48 if ($isMassAction) {
49 $_SESSION['massAction']['actions'] = $action['actions'];
50
51 return true;
52 }
53
54 $action['actions'] = json_encode($action['actions']);
55
56 foreach ($action as $column => $value) {
57 acym_secureDBColumn($column);
58 }
59
60 $action = (object)$action;
61
62 $action->id = $actionClass->save($action);
63
64 return [
65 'automationId' => $automationID,
66 'stepId' => $stepAutomationId,
67 'actionId' => $action->id,
68 ];
69 }
70
71 public function saveExitActions()
72 {
73 $ids = $this->_saveActions();
74
75 if (empty($ids)) {
76 return;
77 }
78
79 acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
80
81 $this->listing();
82 }
83
84 public function saveActions()
85 {
86 $ids = $this->_saveActions();
87
88 if (empty($ids)) {
89 return;
90 }
91
92 acym_setVar('id', $ids['automationId']);
93 acym_setVar('stepId', $ids['stepId']);
94 acym_setVar('actionId', $ids['actionId']);
95 $this->filter();
96 }
97
98 public function createMail()
99 {
100 $id = acym_getVar('int', 'id');
101 $idAdmin = acym_getVar('boolean', 'automation_admin');
102 $type = MailClass::TYPE_AUTOMATION;
103 if ($idAdmin) {
104 $type = 'automation_admin';
105 }
106
107 $and = acym_getVar('string', 'and_action');
108 $this->_saveActions(empty($id));
109
110 $actions = acym_getVar('array', 'acym_action');
111 $mailId = $actions['actions'][$and]['acy_add_queue']['mail_id'];
112 $mailId = empty($mailId) ? '' : '&id='.$mailId;
113
114 $favoriteTemplate = $this->config->get('favorite_template', 0);
115 $startFrom = empty($favoriteTemplate) || !empty($mailId) ? '' : '&from='.$favoriteTemplate;
116
117 acym_redirect(
118 acym_completeLink(
119 'mails&task=edit&step=editEmail&type='.$type.$mailId.'&return='.urlencode(
120 acym_completeLink('automation&task=edit&step=action&id='.$id.'&fromMailEditor=1&mailid={mailid}&and='.$and)
121 ).$startFrom,
122 false,
123 true
124 )
125 );
126 }
127 }
128