Fixed sending confirmation email to new subscribers (first time)

- fixed newsletters listing issue with queue
This commit is contained in:
Jonathan Labreuille
2016-03-02 13:11:06 +01:00
parent 1e7dbc8449
commit 36242bd580
4 changed files with 9 additions and 5 deletions

View File

@@ -135,7 +135,7 @@ define(
}); });
}, },
renderStatus: function(item) { renderStatus: function(item) {
if(item.queue === false) { if(!item.queue) {
return ( return (
<span>Not sent yet.</span> <span>Not sent yet.</span>
); );

View File

@@ -59,7 +59,7 @@ class Initializer {
\ORM::configure('password', Env::$db_password); \ORM::configure('password', Env::$db_password);
\ORM::configure('logging', WP_DEBUG); \ORM::configure('logging', WP_DEBUG);
\ORM::configure('logger', function($query, $time) { \ORM::configure('logger', function($query, $time) {
// error_log("\n".$query."\n"); // error_log("\n".$query."\n");
}); });
\ORM::configure('driver_options', array( \ORM::configure('driver_options', array(

View File

@@ -74,13 +74,14 @@ class Newsletter extends Model {
function withSendingQueue() { function withSendingQueue() {
$queue = $this->getQueue(); $queue = $this->getQueue();
if($queue !== false) { if($queue === false) {
$this->queue = false;
} else {
$this->queue = $queue->asArray(); $this->queue = $queue->asArray();
} }
return $this; return $this;
} }
static function search($orm, $search = '') { static function search($orm, $search = '') {
return $orm->where_like('subject', '%' . $search . '%'); return $orm->where_like('subject', '%' . $search . '%');
} }

View File

@@ -182,8 +182,11 @@ class Subscriber extends Model {
} }
$subscriber = self::createOrUpdate($subscriber_data); $subscriber = self::createOrUpdate($subscriber_data);
$errors = $subscriber->getErrors();
if($errors === false && $subscriber->id > 0) {
$subscriber = self::findOne($subscriber->id);
if($subscriber !== false && $subscriber->id() > 0) {
// restore deleted subscriber // restore deleted subscriber
if($subscriber->deleted_at !== NULL) { if($subscriber->deleted_at !== NULL) {
$subscriber->setExpr('deleted_at', 'NULL'); $subscriber->setExpr('deleted_at', 'NULL');