Add WP user segment selection to Notification and Standard newsletters
This commit is contained in:
@ -9,7 +9,12 @@ import {
|
|||||||
} from 'newsletters/scheduling/common.jsx'
|
} from 'newsletters/scheduling/common.jsx'
|
||||||
|
|
||||||
const availableRoles = window.mailpoet_roles || {};
|
const availableRoles = window.mailpoet_roles || {};
|
||||||
const availableSegments = window.mailpoet_segments || {};
|
const availableSegments = _.filter(
|
||||||
|
window.mailpoet_segments || [],
|
||||||
|
function (segment) {
|
||||||
|
return segment.type === 'default';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const events = {
|
const events = {
|
||||||
name: 'event',
|
name: 'event',
|
||||||
|
@ -383,7 +383,7 @@ class Menu {
|
|||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$data['items_per_page'] = $this->getLimitPerPage('newsletters');
|
$data['items_per_page'] = $this->getLimitPerPage('newsletters');
|
||||||
$data['segments'] = Segment::getPublished()->findArray();
|
$data['segments'] = Segment::getSegmentsWithSubscriberCount($type = false);
|
||||||
$data['settings'] = Setting::getAll();
|
$data['settings'] = Setting::getAll();
|
||||||
$data['roles'] = $wp_roles->get_names();
|
$data['roles'] = $wp_roles->get_names();
|
||||||
$data['roles']['mailpoet_all'] = __('In any WordPress role');
|
$data['roles']['mailpoet_all'] = __('In any WordPress role');
|
||||||
|
@ -139,8 +139,8 @@ class Segment extends Model {
|
|||||||
return $orm;
|
return $orm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSegmentsWithSubscriberCount() {
|
static function getSegmentsWithSubscriberCount($type = 'default') {
|
||||||
return self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
|
$query = self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
|
||||||
->selectExpr(
|
->selectExpr(
|
||||||
self::$_table.'.*, ' .
|
self::$_table.'.*, ' .
|
||||||
'COUNT(IF('.MP_SUBSCRIBER_SEGMENT_TABLE.'.status="' . Subscriber::STATUS_SUBSCRIBED .'" AND '.MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL,1,NULL)) `subscribers`'
|
'COUNT(IF('.MP_SUBSCRIBER_SEGMENT_TABLE.'.status="' . Subscriber::STATUS_SUBSCRIBED .'" AND '.MP_SUBSCRIBERS_TABLE.'.deleted_at IS NULL,1,NULL)) `subscribers`'
|
||||||
@ -154,9 +154,13 @@ class Segment extends Model {
|
|||||||
->groupBy(self::$_table.'.id')
|
->groupBy(self::$_table.'.id')
|
||||||
->groupBy(self::$_table.'.name')
|
->groupBy(self::$_table.'.name')
|
||||||
->orderByAsc(self::$_table.'.name')
|
->orderByAsc(self::$_table.'.name')
|
||||||
->where(self::$_table.'.type', 'default')
|
->whereNull(self::$_table.'.deleted_at');
|
||||||
->whereNull(self::$_table.'.deleted_at')
|
|
||||||
->findArray();
|
if (!empty($type)) {
|
||||||
|
$query->where(self::$_table.'.type', $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->findArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSegmentsForExport($withConfirmedSubscribers = false) {
|
static function getSegmentsForExport($withConfirmedSubscribers = false) {
|
||||||
|
Reference in New Issue
Block a user