diff --git a/ground/controllers/ArticleController.php b/ground/controllers/ArticleController.php index 9f5676d..8fde5fe 100644 --- a/ground/controllers/ArticleController.php +++ b/ground/controllers/ArticleController.php @@ -131,11 +131,19 @@ class ArticleController extends Controller $article->author = App::$user->id; } + if (isset($_POST['save']) && $_POST['save'] == 'published') { + if ($article->status != 'published' || $article->pubDate == 0) { + $article->pubDate = time(); + } + $article->status = 'published'; + } else { + $article->status = 'draft'; + } + $article->title = $title ? $title : 'Без названия'; $article->text = $text; $article->html = $html; $article->status = (isset($_POST['save']) && $_POST['save'] == 'published') ? 'published' : 'draft'; - $article->pubDate = time(); $article->photoId = Helper::getFirstImg($text); $article->allowComments = $allowComments; $article->save();