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/Dashboard/Walkthrough.php +125 -79 10.10.2 → 11.1.0 View file →
@@ -11,56 +11,28 @@
11 11 use AcyMailing\Types\StepsType;
12 12
13 13 trait Walkthrough
14 14 {
15 - public function walkthrough(): bool
15 + public function saveStepThankYou(): void
16 16 {
17 - if ($this->config->get('walk_through', 0) != 1) {
18 - return false;
19 - }
17 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
20 18
21 - $walkthroughParams = json_decode($this->config->get('walkthrough_params', '[]'), true);
22 - if (empty($walkthroughParams['step']) || !method_exists($this, $walkthroughParams['step'])) {
23 - $this->stepThankYou();
24 - } else {
25 - $this->{$walkthroughParams['step']}();
19 + if (!acym_isAllowed('configuration')) {
20 + return;
26 21 }
27 22
28 - return true;
29 - }
30 -
31 - public function stepThankYou(): void
32 - {
33 - acym_setVar('layout', 'step_thank_you');
34 -
35 - $data = [
36 - 'level' => $this->config->get('level'),
37 - ];
38 -
39 - parent::display($data);
40 - }
41 -
42 - public function saveStepThankYou(): void
43 - {
44 23 $this->saveWalkthrough(['step' => 'stepSenderInformation']);
45 24 $this->stepSenderInformation();
46 25 }
47 26
48 - public function stepSenderInformation(): void
27 + public function saveStepSenderInformation(): void
49 28 {
50 - acym_setVar('layout', 'step_sender_information');
29 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
51 30
52 - $data = [
53 - 'stepsType' => new StepsType(),
54 - 'siteName' => $this->config->get('from_name', acym_getCMSConfig('sitename')),
55 - 'userEmail' => $this->config->get('from_email', acym_currentUserEmail()),
56 - ];
31 + if (!acym_isAllowed('configuration')) {
32 + return;
33 + }
57 34
58 - parent::display($data);
59 - }
60 -
61 - public function saveStepSenderInformation(): void
62 - {
63 35 $newConfiguration = [
64 36 'from_name' => acym_getVar('string', 'from_name'),
65 37 'from_email' => acym_getVar('string', 'from_email'),
66 38 ];
@@ -77,24 +49,16 @@
77 49 $this->saveWalkthrough(['step' => 'stepLicense']);
78 50 $this->stepLicense();
79 51 }
80 52
81 - public function stepLicense(): void
53 + public function ajaxAttachLicense(): void
82 54 {
83 - acym_setVar('layout', 'step_license');
55 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
84 56
85 - $data = [
86 - 'stepsType' => new StepsType(),
87 - 'level' => $this->config->get('level'),
88 - ];
57 + if (!acym_isAllowed('configuration')) {
58 + return;
59 + }
89 60
90 - parent::display($data);
91 - }
92 -
93 - public function ajaxAttachLicense(): void
94 - {
95 - acym_checkToken();
96 -
97 61 $licenseKey = acym_getVar('string', 'licenseKey', '');
98 62 if (empty($licenseKey)) {
99 63 acym_sendAjaxResponse(acym_translation('ACYM_LICENSE_NOT_FOUND'), [], false);
100 64 }
@@ -118,10 +82,14 @@
118 82 }
119 83
120 84 public function ajaxActivateCron(): void
121 85 {
122 - acym_checkToken();
86 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
123 87
88 + if (!acym_isAllowed('configuration')) {
89 + return;
90 + }
91 +
124 92 $licenseKey = $this->config->get('license_key');
125 93 if (empty($licenseKey)) {
126 94 acym_sendAjaxResponse(acym_translation('ACYM_LICENSE_NOT_FOUND'), [], false);
127 95 }
@@ -147,14 +115,118 @@
147 115 }
148 116
149 117 public function saveStepLicense(): void
150 118 {
119 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
120 +
121 + if (!acym_isAllowed('configuration')) {
122 + return;
123 + }
124 +
151 125 $this->saveWalkthrough(['step' => 'stepFinal']);
152 126 $this->stepFinal();
153 127 }
154 128
155 - public function stepFinal(): void
129 + public function startUsing(bool $campaigns = false): void
156 130 {
131 + if (!$campaigns) {
132 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
133 + }
134 +
135 + if (!acym_isAllowed('configuration')) {
136 + return;
137 + }
138 +
139 + $this->config->saveConfig(['walk_through' => 0]);
140 + $redirectUrl = $campaigns ? 'campaigns' : 'dashboard';
141 +
142 + acym_redirect(acym_completeLink($redirectUrl, false, true));
143 + }
144 +
145 + public function tryEditor(): void
146 + {
147 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
148 +
149 + if (!acym_isAllowed('configuration')) {
150 + return;
151 + }
152 +
153 + $this->saveWalkthrough(['step' => 'stepEditor']);
154 + $this->stepEditor();
155 + }
156 +
157 + public function saveAjax(): void
158 + {
159 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
160 +
161 + if (!acym_isAllowed('configuration') || $this->config->get('walk_through', 0) != 1) {
162 + return;
163 + }
164 +
165 + $mailController = new MailsController();
166 + $mailId = $mailController->store(true);
167 +
168 + if (!empty($mailId)) {
169 + acym_sendAjaxResponse('', ['result' => $mailId]);
170 + } else {
171 + acym_sendAjaxResponse(acym_translation('ACYM_ERROR_SAVING'), [], false);
172 + }
173 + }
174 +
175 + private function walkthrough(): bool
176 + {
177 + if ($this->config->get('walk_through', 0) != 1 || !acym_isAllowed('configuration')) {
178 + return false;
179 + }
180 +
181 + $walkthroughParams = json_decode($this->config->get('walkthrough_params', '[]'), true);
182 + if (empty($walkthroughParams['step']) || !method_exists($this, $walkthroughParams['step'])) {
183 + $this->stepThankYou();
184 + } else {
185 + $this->{$walkthroughParams['step']}();
186 + }
187 +
188 + return true;
189 + }
190 +
191 + private function stepThankYou(): void
192 + {
193 + acym_setVar('layout', 'step_thank_you');
194 +
195 + $data = [
196 + 'level' => $this->config->get('level'),
197 + ];
198 +
199 + parent::display($data);
200 + }
201 +
202 + private function stepSenderInformation(): void
203 + {
204 + acym_setVar('layout', 'step_sender_information');
205 +
206 + $data = [
207 + 'stepsType' => new StepsType(),
208 + 'siteName' => $this->config->get('from_name', acym_getCMSConfig('sitename')),
209 + 'userEmail' => $this->config->get('from_email', acym_currentUserEmail()),
210 + ];
211 +
212 + parent::display($data);
213 + }
214 +
215 + private function stepLicense(): void
216 + {
217 + acym_setVar('layout', 'step_license');
218 +
219 + $data = [
220 + 'stepsType' => new StepsType(),
221 + 'level' => $this->config->get('level'),
222 + ];
223 +
224 + parent::display($data);
225 + }
226 +
227 + private function stepFinal(): void
228 + {
157 229 $acyMailerApiKey = $this->config->get('acymailer_apikey');
158 230 acym_setVar('layout', empty($acyMailerApiKey) ? 'step_final' : 'step_acymailer');
159 231
160 232 $data = [
@@ -168,24 +240,10 @@
168 240
169 241 parent::display($data);
170 242 }
171 243
172 - public function startUsing(bool $campaigns = false): void
244 + private function stepEditor(): void
173 245 {
174 - $this->config->saveConfig(['walk_through' => 0]);
175 - $redirectUrl = $campaigns ? 'campaigns' : 'dashboard';
176 -
177 - acym_redirect(acym_completeLink($redirectUrl, false, true));
178 - }
179 -
180 - public function tryEditor(): void
181 - {
182 - $this->saveWalkthrough(['step' => 'stepEditor']);
183 - $this->stepEditor();
184 - }
185 -
186 - public function stepEditor(): void
187 - {
188 246 acym_setVar('layout', 'step_editor');
189 247
190 248 $mailClass = new MailClass();
191 249 $mail = $mailClass->getOneByName(acym_translation(UpdateHelper::FIRST_EMAIL_NAME_KEY));
@@ -216,20 +274,8 @@
216 274 'editor' => $editorHelper,
217 275 ];
218 276
219 277 parent::display($data);
220 - }
221 -
222 - public function saveAjax(): void
223 - {
224 - $mailController = new MailsController();
225 - $mailId = $mailController->store(true);
226 -
227 - if (!empty($mailId)) {
228 - acym_sendAjaxResponse('', ['result' => $mailId]);
229 - } else {
230 - acym_sendAjaxResponse(acym_translation('ACYM_ERROR_SAVING'), [], false);
231 - }
232 278 }
233 279
234 280 private function saveWalkthrough(array $params): void
235 281 {