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 +99 -43 10.1.4 → 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,9 +19,10 @@
20 19 public function listing(): void
21 20 {
22 21 acym_setVar('layout', 'listing');
23 22
24 - $this->getAccessToken();
23 + // We check if we have to store a token from an OAuth provider
24 + $this->handleOauthAuthentication();
25 25
26 26 $data = [];
27 27 $data['tab'] = new TabHelper();
28 28 $this->prepareLanguages($data);
@@ -36,13 +36,8 @@
36 36 $this->prepareToolbar($data);
37 37 $this->prepareHoursMinutes($data);
38 38 $this->resetQueueProcess();
39 39
40 - if (ACYM_CMS == 'wordpress' && acym_isExtensionActive('wp-mail-smtp/wp_mail_smtp.php')) {
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);
@@ -57,15 +52,28 @@
57 52 $emailsPerBatch = $this->config->get('queue_nbmail_auto', 70);
58 53 $cronFrequency = $this->config->get('cron_frequency', 900);
59 54 if ($queueType !== 'manual') {
60 55 if (($batchesNumber > 1 || $cronFrequency < 900) && !function_exists('curl_multi_exec')) {
61 - acym_enqueueMessage(acym_translation('ACYM_NEED_CURL_MULTI'), 'error');
56 + $notification = [
57 + 'name' => 'curl_multi_exec',
58 + 'removable' => 0,
59 + ];
60 + acym_enqueueMessage(acym_translation('ACYM_NEED_CURL_MULTI'), 'error', true, [$notification]);
61 + } elseif ($batchesNumber <= 1 && $cronFrequency >= 900) {
62 + acym_removeDashboardNotification('curl_multi_exec');
62 63 }
63 64
64 - if ($batchesNumber > 4 || $emailsPerBatch > 300 || $cronFrequency < 300) {
65 + $remindme = json_decode($this->config->get('remindme', '[]'), true);
66 + if (!in_array('sendoverload', $remindme) && ($batchesNumber > 4 || $emailsPerBatch > 300 || $cronFrequency < 300)) {
65 67 $text = acym_translation('ACYM_SEND_CONFIGURATION_WARNING');
66 68 $text .= '<p class="acym__do__not__remindme" title="sendoverload">'.acym_translation('ACYM_DO_NOT_REMIND_ME').'</p>';
67 - acym_enqueueMessage($text, 'warning');
69 + $notification = [
70 + 'name' => 'sendoverload',
71 + 'removable' => 1,
72 + ];
73 + acym_enqueueMessage($text, 'warning', true, [$notification]);
74 + } else {
75 + acym_removeDashboardNotification('sendoverload');
68 76 }
69 77 }
70 78 }
71 79
@@ -79,11 +87,8 @@
79 87 $data['sendingMethods'] = [];
80 88 acym_trigger('onAcymGetSendingMethods', [&$data]);
81 89 acym_trigger('onAcymGetSendingMethodsSelected', [&$data]);
82 90
83 - $data['sendingMethodsHtmlSettings'] = [];
84 - acym_trigger('onAcymGetSendingMethodsHtmlSetting', [&$data]);
85 -
86 91 $data['embedImage'] = [];
87 92 $data['embedAttachment'] = [];
88 93 acym_trigger('onAcymSendingMethodOptions', [&$data]);
89 94 }
@@ -93,9 +98,9 @@
93 98 $toolbarHelper = new ToolbarHelper();
94 99 $toolbarHelper->addButton(
95 100 acym_translation('ACYM_SEND_TEST'),
96 101 [
97 - 'acym-data-before' => 'jQuery.acymConfigSave();',
102 + 'data-before-action' => 'configSave',
98 103 'data-task' => 'test',
99 104 ]
100 105 );
101 106 $toolbarHelper->addButton(
@@ -100,9 +105,9 @@
100 105 );
101 106 $toolbarHelper->addButton(
102 107 acym_translation('ACYM_SAVE'),
103 108 [
104 - 'acym-data-before' => 'jQuery.acymConfigSave();',
109 + 'data-before-action' => 'configSave',
105 110 'data-task' => 'save',
106 111 ],
107 112 '',
108 113 true
@@ -123,26 +128,17 @@
123 128 $langs = acym_getLanguages();
124 129 $data['languages'] = [];
125 130
126 131 foreach ($langs as $lang => $obj) {
127 - if ($lang === 'xx-XX') continue;
132 + if ($lang === 'xx-XX') {
133 + continue;
134 + }
128 135
129 136 $oneLanguage = new \stdClass();
130 137 $oneLanguage->language = $lang;
131 138 $oneLanguage->name = $obj->name;
139 + $oneLanguage->icon = $obj->exists ? 'edit' : 'add';
132 140
133 - $linkEdit = acym_completeLink('language&task=displayLanguage&code='.$lang, true);
134 - $icon = $obj->exists ? 'edit' : 'add';
135 - $idModalLanguage = 'acym_modal_language_'.$lang;
136 - $oneLanguage->edit = acym_modal(
137 - '<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>',
138 - '', //<iframe src="'.$linkEdit.'"></iframe>
139 - $idModalLanguage,
140 - 'data-reveal-larger',
141 - '',
142 - false
143 - );
144 -
145 141 $data['languages'][] = $oneLanguage;
146 142 }
147 143
148 144 usort(
@@ -210,9 +206,9 @@
210 206 }
211 207
212 208 private function prepareAcl(array &$data): void
213 209 {
214 - $data['acl'] = acym_cmsPermission();
210 + $data['adminPermissions'] = acym_hasAdminPermissions();
215 211 $data['acl_advanced'] = acym_getPagesForAcl();
216 212 $data['aclType'] = new AclType();
217 213 }
218 214
@@ -217,13 +213,13 @@
217 213 }
218 214
219 215 private function prepareSecurity(array &$data): void
220 216 {
217 + $data['wp_mail_smtp_installed'] = ACYM_CMS === 'wordpress' && acym_isExtensionActive('wp-mail-smtp/wp_mail_smtp.php');
221 218 $data['acychecker_installed'] = acym_isAcyCheckerInstalled();
222 219 $data['acychecker_get_link'] = ACYM_ACYCHECKER_WEBSITE.'?utm_source=acymailing_plugin&utm_campaign=get_acychecker&utm_medium=button_configuration_security';
223 220
224 221 $data['level'] = acym_level(ACYM_ESSENTIAL);
225 - $data['labelDropdownCaptcha'] = acym_translation('ACYM_CONFIGURATION_CAPTCHA');
226 222
227 223 $captchaOptions = array_replace(
228 224 [
229 225 'none' => acym_translation('ACYM_NONE'),
@@ -236,9 +232,8 @@
236 232
237 233 $data['captchaOptions'] = $captchaOptions;
238 234
239 235 if (!acym_level(ACYM_ESSENTIAL)) {
240 - $data['labelDropdownCaptcha'] .= ' '.acym_translation('ACYM_PRO_VERSION_ONLY');
241 236 $data['captchaOptions'] = [];
242 237 }
243 238 }
244 239
@@ -255,19 +250,19 @@
255 250
256 251 private function prepareHoursMinutes(array &$data): void
257 252 {
258 253 $listHours = [];
259 - for ($i = 0 ; $i < 24 ; $i++) {
254 + for ($i = 0; $i < 24; $i++) {
260 255 $value = $i < 10 ? '0'.$i : $i;
261 256 $listHours[] = acym_selectOption($value, $value);
262 257 }
263 258 $listMinutes = [];
264 - for ($i = 0 ; $i < 60 ; $i += 5) {
259 + for ($i = 0; $i < 60; $i += 5) {
265 260 $value = $i < 10 ? '0'.$i : $i;
266 261 $listMinutes[] = acym_selectOption($value, $value);
267 262 }
268 263 $listAllMinutes = [];
269 - for ($i = 0 ; $i < 60 ; $i++) {
264 + for ($i = 0; $i < 60; $i++) {
270 265 $value = $i < 10 ? '0'.$i : $i;
271 266 $listAllMinutes[] = acym_selectOption($value, $value);
272 267 }
273 268 $data['listHours'] = $listHours;
@@ -283,9 +278,9 @@
283 278 }
284 279
285 280 public function store(): void
286 281 {
287 - acym_checkToken();
282 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
288 283
289 284 $formData = acym_getVar('array', 'config', []);
290 285 if (empty($formData)) {
291 286 return;
@@ -292,11 +287,12 @@
292 287 }
293 288
294 289 $this->handleReplyTo($formData);
295 290 $this->handleWordWrap($formData);
296 - $this->handleDemoSite($formData);
291 + $this->handleQueueSettings($formData);
297 292 $this->handleAcl($formData);
298 293 $this->handleSelect2Fields($formData);
294 + $this->handleDemoSite($formData);
299 295 $this->handleAcyChecker($formData);
300 296 $this->handleNewDkim($formData);
301 297 $this->handleEmails($formData);
302 298 $this->handleUnsubSurvey($formData);
@@ -302,11 +298,12 @@
302 298 $this->handleUnsubSurvey($formData);
303 299
304 300 acym_trigger('onBeforeSaveConfigFields', [&$formData]);
305 301
302 + // Don't move this line in the if, we need to do it before the save
306 303 $licenseKeyBeforeSave = $this->config->get('license_key');
307 304
308 - if ($this->config->save($formData)) {
305 + if ($this->config->saveConfig($formData)) {
309 306 $this->handleWebsiteLinking($formData, $licenseKeyBeforeSave);
310 307
311 308 acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'));
312 309 } else {
@@ -338,8 +335,50 @@
338 335 $formData['mailer_wordwrap'] = 998;
339 336 }
340 337 }
341 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 +
342 381 private function handleDemoSite(array &$formData): void
343 382 {
344 383 }
345 384
@@ -344,13 +383,13 @@
344 383 }
345 384
346 385 private function handleAcl(array &$formData): void
347 386 {
348 - if (ACYM_PRODUCTION) {
387 + if (ACYM_PRODUCTION && acym_hasAdminPermissions()) {
349 388 $aclPages = array_keys(acym_getPagesForAcl());
350 389 foreach ($aclPages as $page) {
351 390 if (empty($formData['acl_'.$page])) {
352 - $formData['acl_'.$page] = ['all'];
391 + $formData['acl_'.$page] = [ACYM_ADMIN_GROUP];
353 392 }
354 393 }
355 394 }
356 395 }
@@ -366,18 +405,22 @@
366 405 'acy_notification_unsuball',
367 406 'acy_notification_subform',
368 407 'acy_notification_profile',
369 408 'acy_notification_confirm',
370 - 'wp_access',
371 409 'multilingual_languages',
372 410 'allowed_hosts',
373 411 'unsub_survey',
374 412 ];
375 413
414 + if (acym_hasAdminPermissions()) {
415 + $select2Fields[] = 'wp_access';
416 + }
417 +
376 418 foreach ($select2Fields as $oneField) {
377 419 if ($oneField === 'unsub_survey' && !empty($formData[$oneField])) {
378 420 $formData[$oneField] = json_encode($formData[$oneField]);
379 421 }
422 +
380 423 if (empty($formData[$oneField])) {
381 424 $formData[$oneField] = [];
382 425 }
383 426 }
@@ -411,8 +454,9 @@
411 454 }
412 455
413 456 private function handleNewDkim(array &$formData): void
414 457 {
458 + // The user set DKIM as disabled
415 459 if (empty($formData['dkim'])) {
416 460 return;
417 461 }
418 462
@@ -418,12 +462,14 @@
418 462
419 463 $privateKey = $this->config->get('dkim_private');
420 464 $publicKey = $this->config->get('dkim_public');
421 465
466 + // We're manually submitting keys
422 467 if (!empty($formData['dkim_private']) || !empty($formData['dkim_public'])) {
423 468 return;
424 469 }
425 470
471 + // We don't submit keys and stored keys are not empty
426 472 if (!isset($formData['dkim_private']) && !empty($privateKey) && !empty($publicKey)) {
427 473 return;
428 474 }
429 475
@@ -440,8 +486,9 @@
440 486 {
441 487 $isLicenseKeyUpdated = isset($formData['license_key']) && $licenseKeyBeforeSave !== $formData['license_key'];
442 488
443 489 if ($isLicenseKeyUpdated && ACYM_PRODUCTION) {
490 + // If we add a key or edit it, we try to attach it
444 491 if (!empty($formData['license_key'])) {
445 492 $resultAttachLicenseOnUpdateMe = $this->attachLicenseOnUpdateMe($formData['license_key']);
446 493
447 494 if (!empty($resultAttachLicenseOnUpdateMe['message'])) {
@@ -447,8 +494,9 @@
447 494 if (!empty($resultAttachLicenseOnUpdateMe['message'])) {
448 495 $this->displayMessage($resultAttachLicenseOnUpdateMe['message']);
449 496 }
450 497 } else {
498 + // If we remove a key, we try to unlink it
451 499 $resultUnlinkLicenseOnUpdateMe = $this->unlinkLicenseOnUpdateMe($licenseKeyBeforeSave);
452 500
453 501 if (!empty($resultUnlinkLicenseOnUpdateMe['message'])) {
454 502 $this->displayMessage($resultUnlinkLicenseOnUpdateMe['message']);
@@ -453,13 +501,16 @@
453 501 if (!empty($resultUnlinkLicenseOnUpdateMe['message'])) {
454 502 $this->displayMessage($resultUnlinkLicenseOnUpdateMe['message']);
455 503 }
456 504 }
505 +
506 + UpdatemeHelper::getLicenseInfo();
457 507 }
458 508 }
459 509
460 510 private function handleMultilingual(array $formData): void
461 511 {
512 + // Remove unused email translations
462 513 $removed = array_diff(
463 514 explode(',', acym_getVar('string', 'previous_multilingual_languages', '')),
464 515 $formData['multilingual_languages']
465 516 );
@@ -481,8 +532,9 @@
481 532 $mailerHelper->Subject = 'Test e-mail from '.ACYM_LIVE;
482 533 $mailerHelper->Body = acym_translation('ACYM_TEST_EMAIL');
483 534 $mailerHelper->SMTPDebug = 1;
484 535 $mailerHelper->isTest = true;
536 + //We set the full error reporting if we are in debug mode
485 537 if (acym_isDebug()) {
486 538 $mailerHelper->SMTPDebug = 2;
487 539 }
488 540
@@ -528,9 +580,9 @@
528 580 $unsubSurvey = json_decode($formData['unsub_survey'], true);
529 581 if (is_array($unsubSurvey)) {
530 582 foreach ($unsubSurvey as $key => $value) {
531 583 if (is_string($value)) {
532 - $unsubSurvey[$key] = strip_tags($value);
584 + $unsubSurvey[$key] = acym_stripTags($value);
533 585 }
534 586 }
535 587 $formData['unsub_survey'] = json_encode($unsubSurvey);
536 588 }
@@ -542,9 +594,9 @@
542 594 foreach ($unsubSurveyTranslation as $lang => $unsubSurvey) {
543 595 if (is_array($unsubSurvey) && isset($unsubSurvey['unsub_survey'])) {
544 596 foreach ($unsubSurvey['unsub_survey'] as $key => $value) {
545 597 if (is_string($value)) {
546 - $unsubSurveyTranslation[$lang]['unsub_survey'][$key] = strip_tags($value);
598 + $unsubSurveyTranslation[$lang]['unsub_survey'][$key] = acym_stripTags($value);
547 599 }
548 600 }
549 601 }
550 602 }
@@ -555,9 +607,9 @@
555 607
556 608 private function resetQueueProcess(): void
557 609 {
558 610 if (!acym_level(ACYM_ESSENTIAL) && $this->config->get('queue_type', 'manual') !== 'manual') {
559 - $this->config->save(['queue_type' => 'manual']);
611 + $this->config->saveConfig(['queue_type' => 'manual']);
560 612 }
561 613 }
562 614
563 615
@@ -562,8 +614,10 @@
562 614
563 615
564 616 public function addNewSml(): void
565 617 {
618 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
619 +
566 620 acym_trigger('onConfigurationAddSml');
567 621 $this->listing();
568 622 }
569 623
@@ -568,8 +622,10 @@
568 622 }
569 623
570 624 public function deleteSml(): void
571 625 {
626 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
627 +
572 628 acym_trigger('onConfigurationDeleteSml');
573 629 $this->listing();
574 630 }
575 631 }