$article = new Article($_POST['articleId']); $errors = array(); if (!$user->id()) { $errors[] = "Je bent niet ingelogd."; } $article->setSectionId($_POST['sectionId']); // In case of multiple authors who can proofread, amend: don't update unless empty. if (!$article->userId()) { $article->setUserId($user->id()); } $article->setIpAddr($_SERVER['REMOTE_ADDR']); if (isset($_POST['ctime'])) { list($date, $time) = explode(" ", $_POST['ctime']); list($day, $month, $year) = explode("-", $date); $ctime = "{$year}-{$month}-{$day} {$time}"; $article->setCtime($ctime); } else { $showAsPage = true; } if (isset($_POST['cname']) && !count($article->publications())) { // TODO: allow changing when publications exist: 301 redirect must be created somewhere in this case. $article->setCname($_POST['cname']); } $article->setTitle($_POST['title']); $article->setBody($_POST['body']); $article->setFeatured(isset($_POST['featured']) && $_POST['featured'] == 'on' ? 1 : 0); $article->setVisible(isset($_POST['visible']) && $_POST['visible'] == 'on' ? 1 : 0); $article->setHashtags(isset($_POST['hashtags']) ? $_POST['hashtags'] : null); $article->setAlbumId(isset($_POST['albumId']) ? $_POST['albumId'] : null); if (!$article->body()) { $errors[] = "Je kunt geen leeg artikel opslaan!";