Prevent activating email without body

[MAILPOET-2366]
This commit is contained in:
Pavel Dohnal
2019-09-19 15:34:37 +02:00
committed by Jack Kitterhing
parent e56a654b2b
commit 35c9973c85
4 changed files with 25 additions and 2 deletions

View File

@@ -344,6 +344,17 @@ class Newsletter extends Model {
}
function setStatus($status = null) {
if ($status === self::STATUS_ACTIVE) {
if (!$this->body || empty(json_decode($this->body))) {
$this->setError(
Helpers::replaceLinkTags(
__('This is an empty email without any content and it cannot be sent. Please update [link]the email[/link].'),
'admin.php?page=mailpoet-newsletter-editor&id=' . $this->id
)
);
return $this;
}
}
if (in_array($status, [
self::STATUS_DRAFT,
self::STATUS_SCHEDULED,