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/Configuration/Listing.php +81 -39 10.2.2 → 11.1.0 View file →
@@ -9,9 +9,8 @@
9 9 use AcyMailing\Helpers\MailerHelper;
10 10 use AcyMailing\Helpers\TabHelper;
11 11 use AcyMailing\Helpers\ToolbarHelper;
12 12 use AcyMailing\Helpers\UpdatemeHelper;
13 -use AcyMailing\Core\AcymPlugin;
14 13 use AcyMailing\Types\AclType;
15 14 use AcyMailing\Types\DelayType;
16 15 use AcyMailing\Types\FailActionType;
17 16
@@ -20,8 +19,9 @@
20 19 public function listing(): void
21 20 {
22 21 acym_setVar('layout', 'listing');
23 22
23 + // We check if we have to store a token from an OAuth provider
24 24 $this->handleOauthAuthentication();
25 25
26 26 $data = [];
27 27 $data['tab'] = new TabHelper();
@@ -36,13 +36,8 @@
36 36 $this->prepareToolbar($data);
37 37 $this->prepareHoursMinutes($data);
38 38 $this->resetQueueProcess();
39 39
40 - if ($data['wp_mail_smtp_installed']) {
41 - $pluginClass = new AcymPlugin();
42 - $data['button_copy_settings_from'] = $pluginClass->getCopySettingsButton($data, 'from_options', 'wp_mail_smtp');
43 - }
44 -
45 40 $this->prepareMailSettings($data);
46 41 $this->prepareMultilingualOption($data);
47 42
48 43 $this->loadSurveyAnswers($data);
@@ -92,11 +87,8 @@
92 87 $data['sendingMethods'] = [];
93 88 acym_trigger('onAcymGetSendingMethods', [&$data]);
94 89 acym_trigger('onAcymGetSendingMethodsSelected', [&$data]);
95 90
96 - $data['sendingMethodsHtmlSettings'] = [];
97 - acym_trigger('onAcymGetSendingMethodsHtmlSetting', [&$data]);
98 -
99 91 $data['embedImage'] = [];
100 92 $data['embedAttachment'] = [];
101 93 acym_trigger('onAcymSendingMethodOptions', [&$data]);
102 94 }
@@ -106,9 +98,9 @@
106 98 $toolbarHelper = new ToolbarHelper();
107 99 $toolbarHelper->addButton(
108 100 acym_translation('ACYM_SEND_TEST'),
109 101 [
110 - 'acym-data-before' => 'jQuery.acymConfigSave();',
102 + 'data-before-action' => 'configSave',
111 103 'data-task' => 'test',
112 104 ]
113 105 );
114 106 $toolbarHelper->addButton(
@@ -113,9 +105,9 @@
113 105 );
114 106 $toolbarHelper->addButton(
115 107 acym_translation('ACYM_SAVE'),
116 108 [
117 - 'acym-data-before' => 'jQuery.acymConfigSave();',
109 + 'data-before-action' => 'configSave',
118 110 'data-task' => 'save',
119 111 ],
120 112 '',
121 113 true
@@ -136,26 +128,17 @@
136 128 $langs = acym_getLanguages();
137 129 $data['languages'] = [];
138 130
139 131 foreach ($langs as $lang => $obj) {
140 - if ($lang === 'xx-XX') continue;
132 + if ($lang === 'xx-XX') {
133 + continue;
134 + }
141 135
142 136 $oneLanguage = new \stdClass();
143 137 $oneLanguage->language = $lang;
144 138 $oneLanguage->name = $obj->name;
139 + $oneLanguage->icon = $obj->exists ? 'edit' : 'add';
145 140
146 - $linkEdit = acym_completeLink('language&task=displayLanguage&code='.$lang, true);
147 - $icon = $obj->exists ? 'edit' : 'add';
148 - $idModalLanguage = 'acym_modal_language_'.$lang;
149 - $oneLanguage->edit = acym_modal(
150 - '<i class="acymicon-'.$icon.' cursor-pointer acym__color__blue" data-open="'.$idModalLanguage.'" data-ajax="false" data-iframe="'.$linkEdit.'" data-iframe-class="acym__iframe_language" id="image'.$lang.'"></i>',
151 - '', //<iframe src="'.$linkEdit.'"></iframe>
152 - $idModalLanguage,
153 - 'data-reveal-larger',
154 - '',
155 - false
156 - );
157 -
158 141 $data['languages'][] = $oneLanguage;
159 142 }
160 143
161 144 usort(
@@ -223,9 +206,9 @@
223 206 }
224 207
225 208 private function prepareAcl(array &$data): void
226 209 {
227 - $data['acl'] = acym_cmsPermission();
210 + $data['adminPermissions'] = acym_hasAdminPermissions();
228 211 $data['acl_advanced'] = acym_getPagesForAcl();
229 212 $data['aclType'] = new AclType();
230 213 }
231 214
@@ -235,9 +218,8 @@
235 218 $data['acychecker_installed'] = acym_isAcyCheckerInstalled();
236 219 $data['acychecker_get_link'] = ACYM_ACYCHECKER_WEBSITE.'?utm_source=acymailing_plugin&utm_campaign=get_acychecker&utm_medium=button_configuration_security';
237 220
238 221 $data['level'] = acym_level(ACYM_ESSENTIAL);
239 - $data['labelDropdownCaptcha'] = acym_translation('ACYM_CONFIGURATION_CAPTCHA');
240 222
241 223 $captchaOptions = array_replace(
242 224 [
243 225 'none' => acym_translation('ACYM_NONE'),
@@ -250,9 +232,8 @@
250 232
251 233 $data['captchaOptions'] = $captchaOptions;
252 234
253 235 if (!acym_level(ACYM_ESSENTIAL)) {
254 - $data['labelDropdownCaptcha'] .= ' '.acym_translation('ACYM_PRO_VERSION_ONLY');
255 236 $data['captchaOptions'] = [];
256 237 }
257 238 }
258 239
@@ -269,19 +250,19 @@
269 250
270 251 private function prepareHoursMinutes(array &$data): void
271 252 {
272 253 $listHours = [];
273 - for ($i = 0 ; $i < 24 ; $i++) {
254 + for ($i = 0; $i < 24; $i++) {
274 255 $value = $i < 10 ? '0'.$i : $i;
275 256 $listHours[] = acym_selectOption($value, $value);
276 257 }
277 258 $listMinutes = [];
278 - for ($i = 0 ; $i < 60 ; $i += 5) {
259 + for ($i = 0; $i < 60; $i += 5) {
279 260 $value = $i < 10 ? '0'.$i : $i;
280 261 $listMinutes[] = acym_selectOption($value, $value);
281 262 }
282 263 $listAllMinutes = [];
283 - for ($i = 0 ; $i < 60 ; $i++) {
264 + for ($i = 0; $i < 60; $i++) {
284 265 $value = $i < 10 ? '0'.$i : $i;
285 266 $listAllMinutes[] = acym_selectOption($value, $value);
286 267 }
287 268 $data['listHours'] = $listHours;
@@ -297,9 +278,9 @@
297 278 }
298 279
299 280 public function store(): void
300 281 {
301 - acym_checkToken();
282 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
302 283
303 284 $formData = acym_getVar('array', 'config', []);
304 285 if (empty($formData)) {
305 286 return;
@@ -306,11 +287,12 @@
306 287 }
307 288
308 289 $this->handleReplyTo($formData);
309 290 $this->handleWordWrap($formData);
310 - $this->handleDemoSite($formData);
291 + $this->handleQueueSettings($formData);
311 292 $this->handleAcl($formData);
312 293 $this->handleSelect2Fields($formData);
294 + $this->handleDemoSite($formData);
313 295 $this->handleAcyChecker($formData);
314 296 $this->handleNewDkim($formData);
315 297 $this->handleEmails($formData);
316 298 $this->handleUnsubSurvey($formData);
@@ -316,11 +298,12 @@
316 298 $this->handleUnsubSurvey($formData);
317 299
318 300 acym_trigger('onBeforeSaveConfigFields', [&$formData]);
319 301
302 + // Don't move this line in the if, we need to do it before the save
320 303 $licenseKeyBeforeSave = $this->config->get('license_key');
321 304
322 - if ($this->config->save($formData)) {
305 + if ($this->config->saveConfig($formData)) {
323 306 $this->handleWebsiteLinking($formData, $licenseKeyBeforeSave);
324 307
325 308 acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'));
326 309 } else {
@@ -352,8 +335,50 @@
352 335 $formData['mailer_wordwrap'] = 998;
353 336 }
354 337 }
355 338
339 + private function handleQueueSettings(array &$formData): void
340 + {
341 + $currentTaskId = (int)$this->config->get('scheduled_task_id');
342 + $frequency = (int)$formData['cron_frequency'];
343 +
344 + //TODO maybe also handle 15min cron like this
345 + if (
346 + !acym_level(ACYM_ESSENTIAL)
347 + || $formData['queue_type'] === 'manual'
348 + || empty($frequency)
349 + || $frequency === 900
350 + || !acym_isLicenseValidWeekly()
351 + ) {
352 + acym_deleteScheduledTask(
353 + [
354 + 'taskId' => $currentTaskId,
355 + 'type' => 'plg_task_requests_task_get',
356 + 'name' => self::CRON_TASK_NAME,
357 + ]
358 + );
359 + $formData['scheduled_task_id'] = 0;
360 +
361 + return;
362 + }
363 +
364 + $taskId = acym_scheduleTask(
365 + [
366 + 'title' => 'AcyMailing – Automated tasks',
367 + 'type' => 'plg_task_requests_task_get',
368 + 'frequencyInMinutes' => $frequency / 60,
369 + 'name' => self::CRON_TASK_NAME,
370 + 'taskFrequency' => 'every_minute',
371 + 'taskId' => $currentTaskId,
372 + 'config' => $formData,
373 + ]
374 + );
375 +
376 + if (!empty($taskId) && ACYM_CMS === 'joomla') {
377 + $formData['scheduled_task_id'] = $taskId;
378 + }
379 + }
380 +
356 381 private function handleDemoSite(array &$formData): void
357 382 {
358 383 }
359 384
@@ -358,13 +383,13 @@
358 383 }
359 384
360 385 private function handleAcl(array &$formData): void
361 386 {
362 - if (ACYM_PRODUCTION) {
387 + if (ACYM_PRODUCTION && acym_hasAdminPermissions()) {
363 388 $aclPages = array_keys(acym_getPagesForAcl());
364 389 foreach ($aclPages as $page) {
365 390 if (empty($formData['acl_'.$page])) {
366 - $formData['acl_'.$page] = ['all'];
391 + $formData['acl_'.$page] = [ACYM_ADMIN_GROUP];
367 392 }
368 393 }
369 394 }
370 395 }
@@ -380,18 +405,22 @@
380 405 'acy_notification_unsuball',
381 406 'acy_notification_subform',
382 407 'acy_notification_profile',
383 408 'acy_notification_confirm',
384 - 'wp_access',
385 409 'multilingual_languages',
386 410 'allowed_hosts',
387 411 'unsub_survey',
388 412 ];
389 413
414 + if (acym_hasAdminPermissions()) {
415 + $select2Fields[] = 'wp_access';
416 + }
417 +
390 418 foreach ($select2Fields as $oneField) {
391 419 if ($oneField === 'unsub_survey' && !empty($formData[$oneField])) {
392 420 $formData[$oneField] = json_encode($formData[$oneField]);
393 421 }
422 +
394 423 if (empty($formData[$oneField])) {
395 424 $formData[$oneField] = [];
396 425 }
397 426 }
@@ -425,8 +454,9 @@
425 454 }
426 455
427 456 private function handleNewDkim(array &$formData): void
428 457 {
458 + // The user set DKIM as disabled
429 459 if (empty($formData['dkim'])) {
430 460 return;
431 461 }
432 462
@@ -432,12 +462,14 @@
432 462
433 463 $privateKey = $this->config->get('dkim_private');
434 464 $publicKey = $this->config->get('dkim_public');
435 465
466 + // We're manually submitting keys
436 467 if (!empty($formData['dkim_private']) || !empty($formData['dkim_public'])) {
437 468 return;
438 469 }
439 470
471 + // We don't submit keys and stored keys are not empty
440 472 if (!isset($formData['dkim_private']) && !empty($privateKey) && !empty($publicKey)) {
441 473 return;
442 474 }
443 475
@@ -454,8 +486,9 @@
454 486 {
455 487 $isLicenseKeyUpdated = isset($formData['license_key']) && $licenseKeyBeforeSave !== $formData['license_key'];
456 488
457 489 if ($isLicenseKeyUpdated && ACYM_PRODUCTION) {
490 + // If we add a key or edit it, we try to attach it
458 491 if (!empty($formData['license_key'])) {
459 492 $resultAttachLicenseOnUpdateMe = $this->attachLicenseOnUpdateMe($formData['license_key']);
460 493
461 494 if (!empty($resultAttachLicenseOnUpdateMe['message'])) {
@@ -461,8 +494,9 @@
461 494 if (!empty($resultAttachLicenseOnUpdateMe['message'])) {
462 495 $this->displayMessage($resultAttachLicenseOnUpdateMe['message']);
463 496 }
464 497 } else {
498 + // If we remove a key, we try to unlink it
465 499 $resultUnlinkLicenseOnUpdateMe = $this->unlinkLicenseOnUpdateMe($licenseKeyBeforeSave);
466 500
467 501 if (!empty($resultUnlinkLicenseOnUpdateMe['message'])) {
468 502 $this->displayMessage($resultUnlinkLicenseOnUpdateMe['message']);
@@ -467,13 +501,16 @@
467 501 if (!empty($resultUnlinkLicenseOnUpdateMe['message'])) {
468 502 $this->displayMessage($resultUnlinkLicenseOnUpdateMe['message']);
469 503 }
470 504 }
505 +
506 + UpdatemeHelper::getLicenseInfo();
471 507 }
472 508 }
473 509
474 510 private function handleMultilingual(array $formData): void
475 511 {
512 + // Remove unused email translations
476 513 $removed = array_diff(
477 514 explode(',', acym_getVar('string', 'previous_multilingual_languages', '')),
478 515 $formData['multilingual_languages']
479 516 );
@@ -495,8 +532,9 @@
495 532 $mailerHelper->Subject = 'Test e-mail from '.ACYM_LIVE;
496 533 $mailerHelper->Body = acym_translation('ACYM_TEST_EMAIL');
497 534 $mailerHelper->SMTPDebug = 1;
498 535 $mailerHelper->isTest = true;
536 + //We set the full error reporting if we are in debug mode
499 537 if (acym_isDebug()) {
500 538 $mailerHelper->SMTPDebug = 2;
501 539 }
502 540
@@ -542,9 +580,9 @@
542 580 $unsubSurvey = json_decode($formData['unsub_survey'], true);
543 581 if (is_array($unsubSurvey)) {
544 582 foreach ($unsubSurvey as $key => $value) {
545 583 if (is_string($value)) {
546 - $unsubSurvey[$key] = strip_tags($value);
584 + $unsubSurvey[$key] = acym_stripTags($value);
547 585 }
548 586 }
549 587 $formData['unsub_survey'] = json_encode($unsubSurvey);
550 588 }
@@ -556,9 +594,9 @@
556 594 foreach ($unsubSurveyTranslation as $lang => $unsubSurvey) {
557 595 if (is_array($unsubSurvey) && isset($unsubSurvey['unsub_survey'])) {
558 596 foreach ($unsubSurvey['unsub_survey'] as $key => $value) {
559 597 if (is_string($value)) {
560 - $unsubSurveyTranslation[$lang]['unsub_survey'][$key] = strip_tags($value);
598 + $unsubSurveyTranslation[$lang]['unsub_survey'][$key] = acym_stripTags($value);
561 599 }
562 600 }
563 601 }
564 602 }
@@ -569,9 +607,9 @@
569 607
570 608 private function resetQueueProcess(): void
571 609 {
572 610 if (!acym_level(ACYM_ESSENTIAL) && $this->config->get('queue_type', 'manual') !== 'manual') {
573 - $this->config->save(['queue_type' => 'manual']);
611 + $this->config->saveConfig(['queue_type' => 'manual']);
574 612 }
575 613 }
576 614
577 615
@@ -576,8 +614,10 @@
576 614
577 615
578 616 public function addNewSml(): void
579 617 {
618 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
619 +
580 620 acym_trigger('onConfigurationAddSml');
581 621 $this->listing();
582 622 }
583 623
@@ -582,8 +622,10 @@
582 622 }
583 623
584 624 public function deleteSml(): void
585 625 {
626 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
627 +
586 628 acym_trigger('onConfigurationDeleteSml');
587 629 $this->listing();
588 630 }
589 631 }