Server IP : 104.21.14.103 / Your IP : 3.133.153.167 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Newsletter/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Newsletter; if (!defined('ABSPATH')) exit; use MailPoet\Doctrine\Repository; use MailPoet\Entities\NewsletterEntity; use MailPoet\Entities\SendingQueueEntity; use MailPoetVendor\Doctrine\ORM\QueryBuilder; /** * @extends Repository<NewsletterEntity> */ class AutomaticEmailsRepository extends Repository { protected function getEntityClassName() { return NewsletterEntity::class; } public function wasScheduledForSubscriber(int $newsletterId, int $subscriberId): bool { $query = $this->doctrineRepository->createQueryBuilder('n') ->select('COUNT(q)') ->from(SendingQueueEntity::class, 'q'); $query = $this->getAllQueuesForSubscscriberQuery($query, $newsletterId, $subscriberId); $count = $query->getQuery() ->getSingleScalarResult() ?: 0; return ((int)$count) > 0; } private function getAllQueuesForSubscscriberQuery(QueryBuilder $query, int $newsletterId, int $subscriberId): QueryBuilder { return $query ->join('q.task', 't') ->join('t.subscribers', 's') ->andWhere('q.newsletter = :newsletterId') ->andWhere('s.subscriber = :subscriberId') ->setParameter('newsletterId', $newsletterId) ->setParameter('subscriberId', $subscriberId); } /** * Search products/categories in meta if all of the ordered products have already been sent to the subscriber. */ public function alreadySentAllProducts(int $newsletterId, int $subscriberId, string $orderedKey, array $ordered): bool { $query = $this->doctrineRepository->createQueryBuilder('n') ->select('q') ->from(SendingQueueEntity::class, 'q'); $queues = $this->getAllQueuesForSubscscriberQuery($query, $newsletterId, $subscriberId) ->getQuery() ->getResult(); $sent = []; foreach ($queues as $queue) { $meta = $queue->getMeta(); if (isset($meta[$orderedKey])) { $sent = array_merge($sent, $meta[$orderedKey]); } } $notSentProducts = array_diff($ordered, $sent); return empty($notSentProducts); } }