- Adds new model methods
This commit is contained in:
@ -5,4 +5,9 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class NewsletterLink extends Model {
|
||||
public static $_table = MP_NEWSLETTER_LINKS_TABLE;
|
||||
|
||||
static function getByHash($hash) {
|
||||
return parent::where('hash', $hash)
|
||||
->findOne();
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,15 @@ class SendingQueue extends Model {
|
||||
return $subscribers;
|
||||
}
|
||||
|
||||
function getRenderedNewsletterBody() {
|
||||
return json_decode($this->newsletter_rendered_body, true);
|
||||
}
|
||||
|
||||
function isSubscriberProcessed($subscriber_id) {
|
||||
$subscribers = $this->getSubscribers();
|
||||
return in_array($subscriber_id, $subscribers['processed']);
|
||||
}
|
||||
|
||||
function asArray() {
|
||||
$model = parent::asArray();
|
||||
$model['subscribers'] = (is_serialized($this->subscribers))
|
||||
|
@ -5,4 +5,23 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class StatisticsClicks extends Model {
|
||||
public static $_table = MP_STATISTICS_CLICKS_TABLE;
|
||||
|
||||
static function createOrUpdateClickCount($link_id, $subscriber_id, $newsletter_id, $queue_id) {
|
||||
$statistics = self::where('link_id', $link_id)
|
||||
->where('subscriber_id', $subscriber_id)
|
||||
->where('newsletter_id', $newsletter_id)
|
||||
->where('queue_id', $queue_id)
|
||||
->findOne();
|
||||
if(!$statistics) {
|
||||
$statistics = self::create();
|
||||
$statistics->link_id = $link_id;
|
||||
$statistics->subscriber_id = $subscriber_id;
|
||||
$statistics->newsletter_id = $newsletter_id;
|
||||
$statistics->queue_id = $queue_id;
|
||||
$statistics->count = 1;
|
||||
} else {
|
||||
$statistics->count++;
|
||||
}
|
||||
return $statistics->save();
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,19 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class StatisticsOpens extends Model {
|
||||
public static $_table = MP_STATISTICS_OPENS_TABLE;
|
||||
|
||||
static function getOrCreate($subscriber_id, $newsletter_id, $queue_id) {
|
||||
$statistics = self::where('subscriber_id', $subscriber_id)
|
||||
->where('newsletter_id', $newsletter_id)
|
||||
->where('queue_id', $queue_id)
|
||||
->findOne();
|
||||
if(!$statistics) {
|
||||
$statistics = self::create();
|
||||
$statistics->subscriber_id = $subscriber_id;
|
||||
$statistics->newsletter_id = $newsletter_id;
|
||||
$statistics->queue_id = $queue_id;
|
||||
$statistics->save();
|
||||
}
|
||||
return $statistics;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user