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 +37 -10 10.11.1 → 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
@@ -579,12 +582,12 @@
579 582
580 583 return acym_loadObjectList('SELECT * FROM #__acym_followup WHERE `trigger` IN ('.implode(',', $safeTriggers).') AND active = 1');
581 584 }
582 585
583 - public function queueForSubscribers(int $emailId): bool
586 + public function queueForSubscribers(int $emailId): ?int
584 587 {
585 588 if (empty($emailId)) {
586 - return false;
589 + return null;
587 590 }
588 591
589 592 $mailInfo = acym_loadObject(
590 593 'SELECT map.*, followup.list_id
@@ -592,9 +595,9 @@
592 595 JOIN #__acym_followup AS followup
593 596 ON followup.id = map.followup_id
594 597 WHERE map.mail_id = '.intval($emailId)
595 598 );
596 - if (empty($mailInfo)) return false;
599 + if (empty($mailInfo)) return null;
597 600
598 601 $this->addMailStat($mailInfo->mail_id);
599 602
600 603 $delay = intval($mailInfo->delay) * intval($mailInfo->delay_unit);
@@ -603,9 +606,11 @@
603 606 FROM #__acym_user_has_list
604 607 WHERE status = 1
605 608 AND list_id = '.intval($mailInfo->list_id);
606 609
607 - return (bool)acym_query($query);
610 + $addedEmails = acym_query($query);
611 +
612 + return $addedEmails === false || $addedEmails === null ? null : intval($addedEmails);
608 613 }
609 614
610 615 public function getXFollowups(array $options): array
611 616 {
@@ -651,8 +656,13 @@
651 656
652 657 return $followUps;
653 658 }
654 659
660 + /**
661 + * @param string $mailId
662 + *
663 + * @return object|null
664 + */
655 665 public function getOneByMailId(int $mailId): ?object
656 666 {
657 667 return acym_loadObject(
658 668 'SELECT followup.*
@@ -662,8 +672,13 @@
662 672 WHERE mail_id = '.intval($mailId)
663 673 );
664 674 }
665 675
676 + /**
677 + * @param $followupId
678 + *
679 + * @return object
680 + */
666 681 public function getLastEmail(int $followupId): object
667 682 {
668 683 return acym_loadObject(
669 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'
@@ -669,8 +684,16 @@
669 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'
670 685 );
671 686 }
672 687
688 + /**
689 + * @param int $followUpId
690 + * @param int $userId
691 + * @param int $additionalDelay
692 + * @param array $mailIdToSkip
693 + *
694 + * @return void
695 + */
673 696 public function triggerFollowUp(int $followUpId, int $userId, int $additionalDelay = 0, array $mailIdToSkip = []): void
674 697 {
675 698 $followUp = $this->getOneById($followUpId);
676 699
@@ -692,8 +715,12 @@
692 715 $sendDate = time() + (intval($mail->delay) * intval($mail->delay_unit)) + $additionalDelay;
693 716 $sendDate = acym_escapeDB(acym_date($sendDate, 'Y-m-d H:i:s', false));
694 717 $allValues[] = '('.intval($mail->mail_id).', '.intval($userId).', '.$sendDate.', '.$this->config->get('priority_newsletter', 3).', 0'.')';
695 718 }
719 + }
720 +
721 + if (empty($allValues)) {
722 + return;
696 723 }
697 724
698 725 $queryToProcess = 'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`, `priority`, `try`) VALUES '.implode(', ', $allValues);
699 726