Example #1
0
     $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!";
 }
 if (!sizeof($errors)) {
     // Save article prior to publishing to create cname.
     $article->save();
     // Publish article.
     if (isset($_POST['connections'])) {
         foreach ($_POST['connections'] as $id => $value) {
             if ($value != 'on') {