Subscribers limit
- added "limit.html" template - subscribers_limit set in Env class
This commit is contained in:
@ -27,6 +27,7 @@ class Env {
|
|||||||
static $db_password;
|
static $db_password;
|
||||||
static $db_charset;
|
static $db_charset;
|
||||||
static $db_timezone_offset;
|
static $db_timezone_offset;
|
||||||
|
static $subscribers_limit = 2000;
|
||||||
|
|
||||||
static function init($file, $version) {
|
static function init($file, $version) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
@ -34,6 +34,16 @@ class Menu {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkSubscribersLimit() {
|
||||||
|
$subscribers_count = Subscriber::getTotalSubscribers();
|
||||||
|
if($subscribers_count > Env::$subscribers_limit) {
|
||||||
|
echo $this->renderer->render('limit.html', array(
|
||||||
|
'limit' => Env::$subscribers_limit
|
||||||
|
));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
$main_page_slug = 'mailpoet-newsletters';
|
$main_page_slug = 'mailpoet-newsletters';
|
||||||
|
|
||||||
@ -242,6 +252,8 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function settings() {
|
function settings() {
|
||||||
|
$this->checkSubscribersLimit();
|
||||||
|
|
||||||
$settings = Setting::getAll();
|
$settings = Setting::getAll();
|
||||||
$flags = $this->_getFlags();
|
$flags = $this->_getFlags();
|
||||||
|
|
||||||
@ -314,12 +326,16 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function segments() {
|
function segments() {
|
||||||
|
$this->checkSubscribersLimit();
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['items_per_page'] = $this->getLimitPerPage('segments');
|
$data['items_per_page'] = $this->getLimitPerPage('segments');
|
||||||
echo $this->renderer->render('segments.html', $data);
|
echo $this->renderer->render('segments.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function forms() {
|
function forms() {
|
||||||
|
$this->checkSubscribersLimit();
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$data['items_per_page'] = $this->getLimitPerPage('forms');
|
$data['items_per_page'] = $this->getLimitPerPage('forms');
|
||||||
@ -329,6 +345,8 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function newsletters() {
|
function newsletters() {
|
||||||
|
$this->checkSubscribersLimit();
|
||||||
|
|
||||||
global $wp_roles;
|
global $wp_roles;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
@ -624,6 +624,13 @@ class Subscriber extends Model {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function getTotalSubscribers() {
|
||||||
|
return self::whereIn('status', array(
|
||||||
|
self::STATUS_SUBSCRIBED,
|
||||||
|
self::STATUS_UNCONFIRMED
|
||||||
|
))->count();
|
||||||
|
}
|
||||||
|
|
||||||
static function bulkTrash($orm) {
|
static function bulkTrash($orm) {
|
||||||
$count = parent::bulkAction($orm, function($subscriber_ids) {
|
$count = parent::bulkAction($orm, function($subscriber_ids) {
|
||||||
self::rawExecute(join(' ', array(
|
self::rawExecute(join(' ', array(
|
||||||
|
@ -438,6 +438,36 @@ class SubscriberTest extends MailPoetTest {
|
|||||||
expect($subscriber)->notEquals(false);
|
expect($subscriber)->notEquals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testItCanTheTotalNumberOfSubscribers() {
|
||||||
|
// remove all subscribers
|
||||||
|
Subscriber::deleteMany();
|
||||||
|
|
||||||
|
$subscriber_1 = Subscriber::createOrUpdate(array(
|
||||||
|
'email' => 'subscriber_1@mailpoet.com',
|
||||||
|
'status' => Subscriber::STATUS_SUBSCRIBED
|
||||||
|
));
|
||||||
|
|
||||||
|
$subscriber_2 = Subscriber::createOrUpdate(array(
|
||||||
|
'email' => 'subscriber_2@mailpoet.com',
|
||||||
|
'status' => Subscriber::STATUS_UNCONFIRMED
|
||||||
|
));
|
||||||
|
|
||||||
|
$subscriber_3 = Subscriber::createOrUpdate(array(
|
||||||
|
'email' => 'subscriber_3@mailpoet.com',
|
||||||
|
'status' => Subscriber::STATUS_UNSUBSCRIBED
|
||||||
|
));
|
||||||
|
|
||||||
|
// counts only subscribed & unconfirmed users
|
||||||
|
$total = Subscriber::getTotalSubscribers();
|
||||||
|
expect($total)->equals(2);
|
||||||
|
|
||||||
|
$subscriber_1->status = Subscriber::STATUS_UNSUBSCRIBED;
|
||||||
|
$subscriber_1->save();
|
||||||
|
|
||||||
|
$total = Subscriber::getTotalSubscribers();
|
||||||
|
expect($total)->equals(1);
|
||||||
|
}
|
||||||
|
|
||||||
function _after() {
|
function _after() {
|
||||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||||
ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
||||||
|
28
views/limit.html
Normal file
28
views/limit.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<% extends 'layout.html' %>
|
||||||
|
|
||||||
|
<% block content %>
|
||||||
|
|
||||||
|
<div class="wrap about-wrap">
|
||||||
|
<h1><%= __("You've reached the %d subscribers limit!") | format(limit) %></h1>
|
||||||
|
|
||||||
|
<p class="about-text">
|
||||||
|
<%= __("MailPoet 3 is currently limited to %d subscribers.") | format(limit) %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<img
|
||||||
|
src="http://i2.wp.com/www.mailpoet.com/wp-content/uploads/2015/05/sad-cat.gif?resize=500%2C212"
|
||||||
|
alt="sad-cat"
|
||||||
|
width="500"
|
||||||
|
height="212"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<h3><%= __('Immediately, you can:') %></h3>
|
||||||
|
<ul>
|
||||||
|
<li><%= __('Delete unconfirmed subscribers to have less than %d subscribers.') | format(limit) %></li>
|
||||||
|
<li>
|
||||||
|
<a href="https://docs.mailpoet.com/"><%= __('Contact us')%></a>
|
||||||
|
<%= __('to become a Premium beta tester.')%>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% endblock %>
|
@ -50,8 +50,8 @@
|
|||||||
<p><%= __("By sharing your data <i>anonymously</i> with us, you can help us understand how people use MailPoet and what sort of features they like and don't like.") %> <a href="http://docs.mailpoet.com/article/36-share-your-data" target="_blank"><%= __('Find out more') %> →</a>
|
<p><%= __("By sharing your data <i>anonymously</i> with us, you can help us understand how people use MailPoet and what sort of features they like and don't like.") %> <a href="http://docs.mailpoet.com/article/36-share-your-data" target="_blank"><%= __('Find out more') %> →</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="mailpoet_analytics_enabled" value="1"
|
<input type="checkbox" id="mailpoet_analytics_enabled" value="1"
|
||||||
<% if(settings.analytics.enabled) %>checked="checked"<% endif %>
|
<% if(settings.analytics.enabled) %>checked="checked"<% endif %>
|
||||||
/> <%= __("Yes, I want to help!") %>
|
/> <%= __("Yes, I want to help!") %>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
Reference in New Issue
Block a user