- duplicate newsletter now includes options as well - fixed NaN issue in statistics when newsletter is being sent - use constant for scheduled (and put it as the sendingQueue Model level)
42 lines
994 B
PHP
42 lines
994 B
PHP
<?php
|
|
namespace MailPoet\Models;
|
|
|
|
if(!defined('ABSPATH')) exit;
|
|
|
|
class SendingQueue extends Model {
|
|
public static $_table = MP_SENDING_QUEUES_TABLE;
|
|
|
|
const STATUS_COMPLETED = 'completed';
|
|
const STATUS_SCHEDULED = 'scheduled';
|
|
const STATUS_PAUSED = 'paused';
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
function pause() {
|
|
if($this->count_processed === $this->count_total) {
|
|
return false;
|
|
} else {
|
|
$this->set('status', STATUS_PAUSED);
|
|
$this->save();
|
|
return ($this->getErrors() === false && $this->id() > 0);
|
|
}
|
|
}
|
|
|
|
function resume() {
|
|
if($this->count_processed === $this->count_total) {
|
|
return $this->complete();
|
|
} else {
|
|
$this->setExpr('status', 'NULL');
|
|
$this->save();
|
|
return ($this->getErrors() === false && $this->id() > 0);
|
|
}
|
|
}
|
|
|
|
function complete() {
|
|
$this->set('status', self::STATUS_COMPLETED);
|
|
$this->save();
|
|
return ($this->getErrors() === false && $this->id() > 0);
|
|
}
|
|
} |