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/Classes/FollowupClass.php +44 -11 10.10.2 → 11.1.0 View file →
@@ -122,8 +122,9 @@
122 122 $element->open = number_format($element->open / $numberMailSent * 100, 2);
123 123 $element->click = number_format($element->click / $numberMailSent * 100, 2);
124 124 }
125 125
126 + //Tracking sales
126 127 if (!acym_isTrackingSalesActive()) return;
127 128
128 129 $trackingSales = acym_loadObject(
129 130 'SELECT SUM(user_stat.tracking_sale) AS sale, user_stat.currency
@@ -247,14 +248,14 @@
247 248 $list = new \stdClass();
248 249 $list->name = $element->display_name;
249 250 $list->description = '';
250 251 $list->color = '#'.implode('', [
251 - ListClass::COLOR_PARTS[rand(0, 15)],
252 - ListClass::COLOR_PARTS[rand(0, 15)],
253 - ListClass::COLOR_PARTS[rand(0, 15)],
254 - ListClass::COLOR_PARTS[rand(0, 15)],
255 - ListClass::COLOR_PARTS[rand(0, 15)],
256 - ListClass::COLOR_PARTS[rand(0, 15)],
252 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
253 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
254 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
255 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
256 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
257 + ListClass::COLOR_PARTS[acym_rand(0, 15)],
257 258 ]);
258 259 $list->access = '';
259 260 $list->type = ListClass::LIST_TYPE_FOLLOWUP;
260 261 } else {
@@ -403,8 +404,9 @@
403 404 $delaySettings->id = $mail->id;
404 405 $this->getDelaySettingToMail($delaySettings, $id);
405 406
406 407 unset($mail->id);
408 + unset($mail->creator_id);
407 409 $mail->name .= '_copy';
408 410
409 411 $mail->id = $mailClass->save($mail);
410 412 if (empty($mail->id)) {
@@ -471,8 +473,9 @@
471 473 }
472 474
473 475 $followupListIds = [];
474 476 foreach ($followupLists as $listId => $followupList) {
477 + // The user unsubscribed, don't re-subscribe them
475 478 if (in_array($followupList->status, [0, '0'], true)) {
476 479 continue;
477 480 }
478 481
@@ -570,15 +573,21 @@
570 573 {
571 574 $triggers = [];
572 575 acym_trigger('onAcymGetFollowupDailyBases', [&$triggers]);
573 576
574 - return acym_loadObjectList('SELECT * FROM #__acym_followup WHERE `trigger` IN ("'.implode('","', $triggers).'") AND active = 1');
577 + if (empty($triggers)) {
578 + return [];
579 + }
580 +
581 + $safeTriggers = array_map('acym_escapeDB', $triggers);
582 +
583 + return acym_loadObjectList('SELECT * FROM #__acym_followup WHERE `trigger` IN ('.implode(',', $safeTriggers).') AND active = 1');
575 584 }
576 585
577 - public function queueForSubscribers(int $emailId): bool
586 + public function queueForSubscribers(int $emailId): ?int
578 587 {
579 588 if (empty($emailId)) {
580 - return false;
589 + return null;
581 590 }
582 591
583 592 $mailInfo = acym_loadObject(
584 593 'SELECT map.*, followup.list_id
@@ -586,9 +595,9 @@
586 595 JOIN #__acym_followup AS followup
587 596 ON followup.id = map.followup_id
588 597 WHERE map.mail_id = '.intval($emailId)
589 598 );
590 - if (empty($mailInfo)) return false;
599 + if (empty($mailInfo)) return null;
591 600
592 601 $this->addMailStat($mailInfo->mail_id);
593 602
594 603 $delay = intval($mailInfo->delay) * intval($mailInfo->delay_unit);
@@ -597,9 +606,11 @@
597 606 FROM #__acym_user_has_list
598 607 WHERE status = 1
599 608 AND list_id = '.intval($mailInfo->list_id);
600 609
601 - return (bool)acym_query($query);
610 + $addedEmails = acym_query($query);
611 +
612 + return $addedEmails === false || $addedEmails === null ? null : intval($addedEmails);
602 613 }
603 614
604 615 public function getXFollowups(array $options): array
605 616 {
@@ -645,8 +656,13 @@
645 656
646 657 return $followUps;
647 658 }
648 659
660 + /**
661 + * @param string $mailId
662 + *
663 + * @return object|null
664 + */
649 665 public function getOneByMailId(int $mailId): ?object
650 666 {
651 667 return acym_loadObject(
652 668 'SELECT followup.*
@@ -656,8 +672,13 @@
656 672 WHERE mail_id = '.intval($mailId)
657 673 );
658 674 }
659 675
676 + /**
677 + * @param $followupId
678 + *
679 + * @return object
680 + */
660 681 public function getLastEmail(int $followupId): object
661 682 {
662 683 return acym_loadObject(
663 684 'SELECT mail_id as id, delay * delay_unit as totalDelay FROM #__acym_followup_has_mail WHERE followup_id = '.intval($followupId).' ORDER BY totalDelay DESC'
@@ -663,8 +684,16 @@
663 684 'SELECT mail_id as id, delay * delay_unit as totalDelay FROM #__acym_followup_has_mail WHERE followup_id = '.intval($followupId).' ORDER BY totalDelay DESC'
664 685 );
665 686 }
666 687
688 + /**
689 + * @param int $followUpId
690 + * @param int $userId
691 + * @param int $additionalDelay
692 + * @param array $mailIdToSkip
693 + *
694 + * @return void
695 + */
667 696 public function triggerFollowUp(int $followUpId, int $userId, int $additionalDelay = 0, array $mailIdToSkip = []): void
668 697 {
669 698 $followUp = $this->getOneById($followUpId);
670 699
@@ -686,8 +715,12 @@
686 715 $sendDate = time() + (intval($mail->delay) * intval($mail->delay_unit)) + $additionalDelay;
687 716 $sendDate = acym_escapeDB(acym_date($sendDate, 'Y-m-d H:i:s', false));
688 717 $allValues[] = '('.intval($mail->mail_id).', '.intval($userId).', '.$sendDate.', '.$this->config->get('priority_newsletter', 3).', 0'.')';
689 718 }
719 + }
720 +
721 + if (empty($allValues)) {
722 + return;
690 723 }
691 724
692 725 $queryToProcess = 'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`, `priority`, `try`) VALUES '.implode(', ', $allValues);
693 726