Migration fix + removed model instantiation in Listing handler
This commit is contained in:
@@ -121,16 +121,16 @@ define(
|
|||||||
|
|
||||||
var status = '';
|
var status = '';
|
||||||
|
|
||||||
switch(parseInt(subscriber.status, 10)) {
|
switch(subscriber.status) {
|
||||||
case 1:
|
case 'subscribed':
|
||||||
status = 'Subscribed';
|
status = 'Subscribed';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 'unconfirmed':
|
||||||
status = 'Unconfirmed';
|
status = 'Unconfirmed';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case 'unsubscribed':
|
||||||
status = 'Unsubscribed';
|
status = 'Unsubscribed';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ class Migrator {
|
|||||||
'status varchar(12) NOT NULL DEFAULT "unconfirmed",',
|
'status varchar(12) NOT NULL DEFAULT "unconfirmed",',
|
||||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
'PRIMARY KEY (id),',
|
'PRIMARY KEY (id),',
|
||||||
'UNIQUE KEY email (email)'
|
'UNIQUE KEY email (email)'
|
||||||
);
|
);
|
||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
@@ -60,7 +60,7 @@ class Migrator {
|
|||||||
'value varchar(255) NOT NULL,',
|
'value varchar(255) NOT NULL,',
|
||||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
'PRIMARY KEY (id),',
|
'PRIMARY KEY (id),',
|
||||||
'UNIQUE KEY name (name)'
|
'UNIQUE KEY name (name)'
|
||||||
);
|
);
|
||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
@@ -73,7 +73,7 @@ class Migrator {
|
|||||||
'body longtext,',
|
'body longtext,',
|
||||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
'PRIMARY KEY (id)'
|
'PRIMARY KEY (id)'
|
||||||
);
|
);
|
||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ class Handler {
|
|||||||
private $model = null;
|
private $model = null;
|
||||||
|
|
||||||
function __construct($model, $data = array()) {
|
function __construct($model, $data = array()) {
|
||||||
$this->model = $this->getModel($model);
|
$this->model = $model;
|
||||||
$this->data = array(
|
$this->data = array(
|
||||||
// pagination
|
// pagination
|
||||||
'offset' => (isset($data['offset']) ? (int)$data['offset'] : 0),
|
'offset' => (isset($data['offset']) ? (int)$data['offset'] : 0),
|
||||||
@@ -28,10 +28,6 @@ class Handler {
|
|||||||
$this->setGroup();
|
$this->setGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getModel($model) {
|
|
||||||
return \Model::factory('\MailPoet\Models\\'.$model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setSearch() {
|
private function setSearch() {
|
||||||
if($this->data['search'] === null) {
|
if($this->data['search'] === null) {
|
||||||
return;
|
return;
|
||||||
|
@@ -12,7 +12,10 @@ class Newsletters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get($data = array()) {
|
function get($data = array()) {
|
||||||
$listing = new Listing\Handler('Newsletter', $data);
|
$listing = new Listing\Handler(
|
||||||
|
\Model::factory('\MailPoet\Models\Newsletter'),
|
||||||
|
$data
|
||||||
|
);
|
||||||
wp_send_json($listing->get());
|
wp_send_json($listing->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,10 @@ class Subscribers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get($data = array()) {
|
function get($data = array()) {
|
||||||
$listing = new Listing\Handler('Subscriber', $data);
|
$listing = new Listing\Handler(
|
||||||
|
\Model::factory('\MailPoet\Models\Subscriber'),
|
||||||
|
$data
|
||||||
|
);
|
||||||
wp_send_json($listing->get());
|
wp_send_json($listing->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user