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/ToggleController.php +0 -225 10.2.2 → 11.1.1 View file →
@@ -1,225 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers;
4 -
5 -use AcyMailing\Classes\UserClass;
6 -use AcyMailing\Core\AcymController;
7 -
8 -class ToggleController extends AcymController
9 -{
10 - protected array $toggleableColumns = [];
11 - protected array $icons = [];
12 - protected array $tooltips = [];
13 - private array $deletableRows = [];
14 -
15 - public function __construct()
16 - {
17 - parent::__construct();
18 -
19 - $this->defaulttask = 'toggle';
20 -
21 - $this->defineToggles();
22 -
23 - acym_noCache();
24 - }
25 -
26 - protected function defineToggles(): void
27 - {
28 - $this->toggleableColumns['automation'] = ['active' => 'id'];
29 - $this->toggleableColumns['field'] = [
30 - 'active' => 'id',
31 - 'required' => 'id',
32 - 'backend_edition' => 'id',
33 - 'backend_listing' => 'id',
34 - 'frontend_edition' => 'id',
35 - 'frontend_listing' => 'id',
36 - ];
37 - $this->toggleableColumns['list'] = ['active' => 'id', 'visible' => 'id'];
38 - $this->toggleableColumns['rule'] = ['active' => 'id'];
39 - $this->toggleableColumns['user'] = ['active' => 'id', 'confirmed' => 'id'];
40 - $this->toggleableColumns['form'] = ['active' => 'id'];
41 - $this->toggleableColumns['segment'] = ['active' => 'id'];
42 - $this->toggleableColumns['campaign'] = ['visible' => 'id'];
43 - $this->toggleableColumns['followup'] = ['active' => 'id'];
44 - $this->toggleableColumns['mail_override'] = ['active' => 'id'];
45 - $this->toggleableColumns['mailbox_action'] = ['active' => 'id'];
46 - $this->toggleableColumns['scenario'] = ['active' => 'id'];
47 -
48 - $this->icons['automation']['active'][1] = 'acymicon-check-circle acym__color__green';
49 - $this->icons['automation']['active'][0] = 'acymicon-times-circle acym__color__red';
50 - $this->icons['field']['active'][1] = 'acymicon-check-circle acym__color__green';
51 - $this->icons['field']['active'][0] = 'acymicon-times-circle acym__color__red';
52 - $this->icons['field']['required'][1] = 'acymicon-check-circle acym__color__green';
53 - $this->icons['field']['required'][0] = 'acymicon-times-circle acym__color__red';
54 - $this->icons['field']['backend_edition'][1] = 'acymicon-check-circle acym__color__green';
55 - $this->icons['field']['backend_edition'][0] = 'acymicon-times-circle acym__color__red';
56 - $this->icons['field']['backend_listing'][1] = 'acymicon-check-circle acym__color__green';
57 - $this->icons['field']['backend_listing'][0] = 'acymicon-times-circle acym__color__red';
58 - $this->icons['field']['frontend_edition'][1] = 'acymicon-check-circle acym__color__green';
59 - $this->icons['field']['frontend_edition'][0] = 'acymicon-times-circle acym__color__red';
60 - $this->icons['field']['frontend_listing'][1] = 'acymicon-check-circle acym__color__green';
61 - $this->icons['field']['frontend_listing'][0] = 'acymicon-times-circle acym__color__red';
62 - $this->icons['list']['active'][1] = 'acymicon-check-circle acym__color__green';
63 - $this->icons['list']['active'][0] = 'acymicon-times-circle acym__color__red';
64 - $this->icons['list']['visible'][1] = 'acymicon-eye';
65 - $this->icons['list']['visible'][0] = 'acymicon-eye-slash acym__color__dark-gray';
66 - $this->icons['rule']['active'][0] = 'acymicon-times-circle acym__color__red';
67 - $this->icons['rule']['active'][1] = 'acymicon-check-circle acym__color__green';
68 - $this->icons['user']['active'][1] = 'acymicon-check-circle acym__color__green';
69 - $this->icons['user']['active'][0] = 'acymicon-times-circle acym__color__red';
70 - $this->icons['user']['confirmed'][1] = 'acymicon-check-circle acym__color__green';
71 - $this->icons['user']['confirmed'][0] = 'acymicon-times-circle acym__color__red';
72 - $this->icons['form']['active'][1] = 'acymicon-check-circle acym__color__green';
73 - $this->icons['form']['active'][0] = 'acymicon-times-circle acym__color__red';
74 - $this->icons['segment']['active'][1] = 'acymicon-check-circle acym__color__green';
75 - $this->icons['segment']['active'][0] = 'acymicon-times-circle acym__color__red';
76 - $this->icons['campaign']['visible'][1] = 'acymicon-eye';
77 - $this->icons['campaign']['visible'][0] = 'acymicon-eye-slash acym__color__dark-gray';
78 - $this->icons['followup']['active'][1] = 'acymicon-check-circle acym__color__green';
79 - $this->icons['followup']['active'][0] = 'acymicon-times-circle acym__color__red';
80 - $this->icons['mail_override']['active'][1] = 'acymicon-check-circle acym__color__green';
81 - $this->icons['mail_override']['active'][0] = 'acymicon-times-circle acym__color__red';
82 - $this->icons['mailbox_action']['active'][1] = 'acymicon-check-circle acym__color__green';
83 - $this->icons['mailbox_action']['active'][0] = 'acymicon-times-circle acym__color__red';
84 - $this->icons['scenario']['active'][1] = 'acymicon-check-circle acym__color__green';
85 - $this->icons['scenario']['active'][0] = 'acymicon-times-circle acym__color__red';
86 -
87 - $this->tooltips['user']['active'][1] = 'ACYM_ACTIVATED';
88 - $this->tooltips['user']['active'][0] = 'ACYM_DEACTIVATED';
89 - $this->tooltips['user']['confirmed'][1] = 'ACYM_CONFIRMED';
90 - $this->tooltips['user']['confirmed'][0] = 'ACYM_NOT_CONFIRMED';
91 - $this->tooltips['list']['active'][1] = 'ACYM_ACTIVATED';
92 - $this->tooltips['list']['active'][0] = 'ACYM_DEACTIVATED';
93 - $this->tooltips['list']['visible'][1] = 'ACYM_VISIBLE';
94 - $this->tooltips['list']['visible'][0] = 'ACYM_INVISIBLE';
95 - $this->tooltips['campaign']['visible'][0] = 'ACYM_INVISIBLE';
96 - $this->tooltips['campaign']['visible'][1] = 'ACYM_VISIBLE';
97 - $this->tooltips['mail_override']['active'][0] = 'ACYM_INACTIVE';
98 - $this->tooltips['mail_override']['active'][1] = 'ACYM_ACTIVE';
99 -
100 - $this->deletableRows[] = 'mail';
101 - $this->deletableRows[] = 'queue';
102 - }
103 -
104 - public function toggle(): void
105 - {
106 - acym_checkToken();
107 -
108 - $table = acym_getVar('word', 'table', '');
109 - $field = acym_getVar('cmd', 'field', '');
110 - $id = acym_getVar('int', 'id', 0);
111 - $newValue = acym_getVar('int', 'value', 0);
112 - if (!empty($newValue)) {
113 - $newValue = 1;
114 - }
115 -
116 - if (empty($table) || empty($field) || empty($id) || empty($this->toggleableColumns[$table][$field])) {
117 - exit;
118 - }
119 -
120 - $preciseMethod = $table.ucfirst($field);
121 - $globalMethod = $table.'Global';
122 - if (method_exists($this, $preciseMethod)) {
123 - $this->$preciseMethod($id, $table, $field, $newValue);
124 - } elseif (method_exists($this, $globalMethod)) {
125 - $this->$globalMethod($id, $table, $field, $newValue);
126 - } else {
127 - $this->doToggle($id, $table, $field, $newValue);
128 - }
129 -
130 - acym_trigger('onAcymToggle'.ucfirst($table).ucfirst($field), [&$id, &$newValue]);
131 -
132 - if (empty($this->icons[$table][$field][$newValue])) {
133 - acym_sendAjaxResponse(acym_translation('ACYM_UNAUTHORIZED_ACCESS'), [], false);
134 - }
135 -
136 - $data = [];
137 - $data['value'] = 1 - $newValue;
138 - $data['classes'] = 'acym_toggleable '.$this->icons[$table][$field][$newValue];
139 -
140 - if (!empty($this->tooltips[$table][$field][$newValue])) {
141 - $data['tooltip'] = ucfirst(acym_translation($this->tooltips[$table][$field][$newValue]));
142 - }
143 -
144 - acym_sendAjaxResponse('', $data);
145 - }
146 -
147 - protected function doToggle(int $id, string $table, string $field, int $newValue): void
148 - {
149 - $updateQuery = 'UPDATE '.acym_secureDBColumn(ACYM_DBPREFIX.$table);
150 - $updateQuery .= ' SET `'.acym_secureDBColumn($field).'` = '.$newValue;
151 - $updateQuery .= ' WHERE `'.acym_secureDBColumn($this->toggleableColumns[$table][$field]).'` = '.$id;
152 - $updateQuery .= ' LIMIT 1';
153 - acym_query($updateQuery);
154 - }
155 -
156 - public function delete(): void
157 - {
158 - if (!acym_isAdmin()) exit;
159 - acym_checkToken();
160 -
161 - $table = acym_getVar('word', 'table', '');
162 - $id = acym_getVar('cmd', 'id', 0);
163 - $method = acym_getVar('word', 'method', 'delete');
164 -
165 - if (empty($table) || !in_array($table, $this->deletableRows) || empty($id)) {
166 - exit;
167 - }
168 -
169 - $namespaceClass = 'AcyMailing\\Classes\\'.ucfirst($table).'Class';
170 - $elementClass = new $namespaceClass;
171 - $elementClass->$method($id);
172 -
173 - exit;
174 - }
175 -
176 - public function setDoNotRemindMe(): void
177 - {
178 - $newValue = acym_getVar('string', 'value');
179 -
180 - if (empty($newValue)) {
181 - acym_sendAjaxResponse(acym_translation('ACYM_ERROR_SAVING'), [], false);
182 - }
183 -
184 - $newConfig = new \stdClass();
185 - $newConfig->remindme = json_decode($this->config->get('remindme', '[]'));
186 - if (!in_array($newValue, $newConfig->remindme)) array_push($newConfig->remindme, $newValue);
187 - $newConfig->remindme = json_encode($newConfig->remindme);
188 -
189 - if ($this->config->save($newConfig)) {
190 - acym_sendAjaxResponse(acym_translation('ACYM_THANKS'));
191 - } else {
192 - acym_sendAjaxResponse(acym_translation('ACYM_ERROR_SAVING'), [], false);
193 - }
194 - }
195 -
196 - public function subscribeOnClick(): void
197 - {
198 - $userId = acym_getVar('int', 'userid');
199 - $listId = acym_getVar('int', 'listid');
200 -
201 - $userClass = new UserClass();
202 - $result = $userClass->subscribe($userId, [$listId]);
203 -
204 - if ($result) {
205 - acym_sendAjaxResponse();
206 - } else {
207 - acym_sendAjaxResponse('', [], false);
208 - }
209 - }
210 -
211 - public function unsubscribeOnClick(): void
212 - {
213 - $userId = acym_getVar('int', 'userid');
214 - $listId = acym_getVar('int', 'listid');
215 -
216 - $userClass = new UserClass();
217 - $result = $userClass->unsubscribe($userId, [$listId]);
218 -
219 - if ($result) {
220 - acym_sendAjaxResponse();
221 - } else {
222 - acym_sendAjaxResponse('', [], false);
223 - }
224 - }
225 -}