Example #1
0
use Kiki\Article;
use Kiki\Album;
use Kiki\Router;
//  require_once "../../lib/init.php";
if ($_POST) {
    $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);