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/Action.php +20 -22 10.0.1 → 11.1.0 View file →
@@ -11,9 +11,9 @@
11 11 use AcyMailing\Helpers\WorkflowHelper;
12 12
13 13 trait Action
14 14 {
15 - public function action()
15 + public function action(): void
16 16 {
17 17
18 18 if (!acym_level(ACYM_ENTERPRISE)) {
19 19 acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
@@ -19,14 +19,10 @@
19 19 acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
20 20 }
21 21 }
22 22
23 - private function _saveActions($isMassAction = false)
23 + private function getSaveActions(bool $isMassAction = false): array
24 24 {
25 - if ($isMassAction) {
26 - acym_session();
27 - }
28 -
29 25 $automationID = acym_getVar('int', 'id');
30 26 $actionId = acym_getVar('int', 'actionId');
31 27 $action = acym_getVar('array', 'acym_action');
32 28 $actionClass = new ActionClass();
@@ -45,11 +41,13 @@
45 41 $action['actions'] = [];
46 42 }
47 43
48 44 if ($isMassAction) {
49 - $_SESSION['massAction']['actions'] = $action['actions'];
45 + $massAction = acym_getVar('array', 'massAction', [], 'SESSION');
46 + $massAction['actions'] = $action['actions'];
47 + acym_setSession('massAction', $massAction);
50 48
51 - return true;
49 + return [];
52 50 }
53 51
54 52 $action['actions'] = json_encode($action['actions']);
55 53
@@ -56,8 +54,9 @@
56 54 foreach ($action as $column => $value) {
57 55 acym_secureDBColumn($column);
58 56 }
59 57
58 + //We need an object to save it so we make a object
60 59 $action = (object)$action;
61 60
62 61 $action->id = $actionClass->save($action);
63 62
@@ -67,28 +66,24 @@
67 66 'actionId' => $action->id,
68 67 ];
69 68 }
70 69
71 - public function saveExitActions()
70 + public function saveExitActions(): void
72 71 {
73 - $ids = $this->_saveActions();
72 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
74 73
75 - if (empty($ids)) {
76 - return;
77 - }
74 + $this->getSaveActions();
78 75
79 - acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
76 + acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'));
80 77
81 78 $this->listing();
82 79 }
83 80
84 - public function saveActions()
81 + public function saveActions(): void
85 82 {
86 - $ids = $this->_saveActions();
83 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
87 84
88 - if (empty($ids)) {
89 - return;
90 - }
85 + $ids = $this->getSaveActions();
91 86
92 87 acym_setVar('id', $ids['automationId']);
93 88 acym_setVar('stepId', $ids['stepId']);
94 89 acym_setVar('actionId', $ids['actionId']);
@@ -94,10 +89,12 @@
94 89 acym_setVar('actionId', $ids['actionId']);
95 90 $this->filter();
96 91 }
97 92
98 - public function createMail()
93 + public function createMail(): void
99 94 {
95 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
96 +
100 97 $id = acym_getVar('int', 'id');
101 98 $idAdmin = acym_getVar('boolean', 'automation_admin');
102 99 $type = MailClass::TYPE_AUTOMATION;
103 100 if ($idAdmin) {
@@ -104,15 +101,16 @@
104 101 $type = 'automation_admin';
105 102 }
106 103
107 104 $and = acym_getVar('string', 'and_action');
108 - $this->_saveActions(empty($id));
105 + $this->getSaveActions(empty($id));
109 106
110 107 $actions = acym_getVar('array', 'acym_action');
111 108 $mailId = $actions['actions'][$and]['acy_add_queue']['mail_id'];
112 109 $mailId = empty($mailId) ? '' : '&id='.$mailId;
113 110
114 - $favoriteTemplate = $this->config->get('favorite_template', 0);
111 + $mailClass = new MailClass();
112 + $favoriteTemplate = $mailClass->getFavoriteTemplateId();
115 113 $startFrom = empty($favoriteTemplate) || !empty($mailId) ? '' : '&from='.$favoriteTemplate;
116 114
117 115 acym_redirect(
118 116 acym_completeLink(