[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.222.67.8: ~ $
<?php

namespace MailPoet\Models;

if (!defined('ABSPATH')) exit;


use MailPoet\Entities\SendingQueueEntity;
use MailPoet\Util\Helpers;
use MailPoet\WP\Functions as WPFunctions;

/**
 * @property int $countProcessed
 * @property int $countToProcess
 * @property int $countTotal
 * @property string|array $newsletterRenderedBody
 * @property string $newsletterRenderedSubject
 * @property int $taskId
 * @property int $newsletterId
 * @property string|object|array|null $meta
 * @property string|array $subscribers
 * @property string|null $deletedAt
 * @property string $scheduledAt
 * @property string $status
 */

class SendingQueue extends Model {
  public static $_table = MP_SENDING_QUEUES_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration
  const STATUS_COMPLETED = SendingQueueEntity::STATUS_COMPLETED;
  const STATUS_SCHEDULED = SendingQueueEntity::STATUS_SCHEDULED;
  const STATUS_PAUSED = SendingQueueEntity::STATUS_PAUSED;
  const PRIORITY_HIGH = SendingQueueEntity::PRIORITY_HIGH;
  const PRIORITY_MEDIUM = SendingQueueEntity::PRIORITY_MEDIUM;
  const PRIORITY_LOW = SendingQueueEntity::PRIORITY_LOW;

  public function __construct() {
    parent::__construct();

    $this->addValidations('newsletter_rendered_body', [
      'validRenderedNewsletterBody' => WPFunctions::get()->__('Rendered newsletter body is invalid!', 'mailpoet'),
    ]);
  }

  public function task() {
    return $this->hasOne(__NAMESPACE__ . '\ScheduledTask', 'id', 'task_id');
  }

  public function newsletter() {
    return $this->has_one(__NAMESPACE__ . '\Newsletter', 'id', 'newsletter_id');
  }

  public function pause() {
    if ($this->countProcessed === $this->countTotal) {
      return false;
    } else {
      return $this->task()->findOne()->pause();
    }
  }

  public function resume() {
    if ($this->countProcessed === $this->countTotal) {
      return $this->complete();
    } else {
      $this->newsletter()->findOne()->setStatus(Newsletter::STATUS_SENDING);
      return $this->task()->findOne()->resume();
    }
  }

  public function complete() {
    return $this->task()->findOne()->complete();
  }

  public function save() {
    $this->newsletterRenderedBody = $this->getNewsletterRenderedBody();
    if (!Helpers::isJson($this->newsletterRenderedBody) && !is_null($this->newsletterRenderedBody)) {
      $this->set(
        'newsletter_rendered_body',
        (string)json_encode($this->newsletterRenderedBody)
      );
    }
    if (!is_null($this->meta) && !Helpers::isJson($this->meta)) {
      $this->set(
        'meta',
        (string)json_encode($this->meta)
      );
    }
    parent::save();
    $this->newsletterRenderedBody = $this->getNewsletterRenderedBody();
    return $this;
  }

  public function getNewsletterRenderedBody($type = false) {
    $renderedNewsletter = $this->decodeRenderedNewsletterBodyObject($this->newsletterRenderedBody);
    return ($type && !empty($renderedNewsletter[$type])) ?
      $renderedNewsletter[$type] :
      $renderedNewsletter;
  }

  public function getMeta() {
    return (Helpers::isJson($this->meta) && is_string($this->meta)) ? json_decode($this->meta, true) : $this->meta;
  }

  public function asArray() {
    $model = parent::asArray();
    $model['newsletter_rendered_body'] = $this->getNewsletterRenderedBody();
    $model['meta'] = $this->getMeta();
    return $model;
  }

  private function decodeRenderedNewsletterBodyObject($renderedBody) {
    if (is_serialized($renderedBody)) {
      return unserialize($renderedBody);
    }
    if (Helpers::isJson($renderedBody)) {
      return json_decode($renderedBody, true);
    }
    return $renderedBody;
  }

  public static function getTasks() {
    return ScheduledTask::tableAlias('tasks')
    ->selectExpr('tasks.*')
    ->join(
      MP_SENDING_QUEUES_TABLE,
      'tasks.id = queues.task_id',
      'queues'
    );
  }

  public static function joinWithTasks() {
    return static::tableAlias('queues')
    ->join(
      MP_SCHEDULED_TASKS_TABLE,
      'tasks.id = queues.task_id',
      'tasks'
    );
  }

  public static function joinWithSubscribers() {
    return static::joinWithTasks()
    ->join(
      MP_SCHEDULED_TASK_SUBSCRIBERS_TABLE,
      'tasks.id = subscribers.task_id',
      'subscribers'
    );
  }

  public static function findTaskByNewsletterId($newsletterId) {
    return static::getTasks()
    ->where('queues.newsletter_id', $newsletterId);
  }
}

Filemanager

Name Type Size Permission Actions
CustomField.php File 3.79 KB 0644
DynamicSegment.php File 4.05 KB 0644
DynamicSegmentFilter.php File 1.35 KB 0644
Form.php File 4.02 KB 0644
MappingToExternalEntities.php File 378 B 0644
Model.php File 13.58 KB 0644
ModelValidator.php File 2.44 KB 0644
Newsletter.php File 15.14 KB 0644
NewsletterLink.php File 530 B 0644
NewsletterOption.php File 670 B 0644
NewsletterOptionField.php File 939 B 0644
NewsletterSegment.php File 312 B 0644
ScheduledTask.php File 6.58 KB 0644
ScheduledTaskSubscriber.php File 5.31 KB 0644
Segment.php File 10.89 KB 0644
SendingQueue.php File 4.31 KB 0644
StatisticsClicks.php File 1.08 KB 0644
StatisticsForms.php File 1.85 KB 0644
StatisticsNewsletters.php File 1.61 KB 0644
StatisticsOpens.php File 807 B 0644
StatisticsUnsubscribes.php File 821 B 0644
StatisticsWooCommercePurchases.php File 1.5 KB 0644
Subscriber.php File 20.83 KB 0644
SubscriberCustomField.php File 2.5 KB 0644
SubscriberIP.php File 1.12 KB 0644
SubscriberSegment.php File 5.2 KB 0644
index.php File 0 B 0644