Server IP : 104.21.14.103 / Your IP : 18.216.182.53 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/Tasks/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Tasks; if (!defined('ABSPATH')) exit; use MailPoet\Models\ScheduledTask; use MailPoet\Models\ScheduledTaskSubscriber; class Subscribers { private $task; public function __construct( ScheduledTask $task ) { $this->task = $task; } public function setSubscribers(array $subscriberIds) { ScheduledTaskSubscriber::setSubscribers($this->task->id, $subscriberIds); } public function getSubscribers() { return ScheduledTaskSubscriber::where('task_id', $this->task->id); } public function removeSubscribers(array $subscribersToRemove) { $this->getSubscribers() ->whereIn('subscriber_id', $subscribersToRemove) ->deleteMany(); $this->checkCompleted(); } public function removeAllSubscribers() { $this->getSubscribers() ->deleteMany(); $this->checkCompleted(); } public function updateProcessedSubscribers(array $processedSubscribers) { if (!empty($processedSubscribers)) { ScheduledTaskSubscriber::rawExecute(sprintf( 'UPDATE %1$s SET processed = %2$s WHERE task_id = %3$s AND subscriber_id IN (%4$s)', ScheduledTaskSubscriber::$_table, ScheduledTaskSubscriber::STATUS_PROCESSED, $this->task->id, join(', ', array_map('intval', $processedSubscribers)) )); } $this->checkCompleted(); } public function saveSubscriberError($subcriberId, $errorMessage) { $this->getSubscribers() ->where('subscriber_id', $subcriberId) ->findResultSet() ->set('failed', ScheduledTaskSubscriber::FAIL_STATUS_FAILED) ->set('processed', ScheduledTaskSubscriber::STATUS_PROCESSED) ->set('error', $errorMessage) ->save(); $this->checkCompleted(); } private function checkCompleted($count = null) { if (!$count && !ScheduledTaskSubscriber::getUnprocessedCount($this->task->id)) { $this->task->complete(); } } }