Example #1
0
if (!$user->isAdmin()) {
    $this->template = 'pages/admin-required';
    return;
}
$this->template = 'pages/admin';
ob_start();
if (isset($_GET['id'])) {
    $id = isset($_GET['id']) ? $_GET['id'] : 0;
    $article = new Article($id);
    $album = new Album($article->albumId());
    // Create album for this article if it doesn't exist yet.
    if (!$album->id()) {
        $album->setSystem(true);
        $album->setTitle($article->title());
        $album->save();
        $article->setAlbumId($album->id());
        if ($article->id()) {
            $article->save();
        }
    }
    echo $article->form();
    if ($album->id()) {
        echo $album->form();
    }
} else {
    echo "<table>\n";
    echo "<thead>\n";
    echo "<tr>\n";
    echo "<td colspan=\"3\"><a href=\"?id=0\"><img src=\"/kiki/img/iconic/black/pen_alt_fill_16x16.png\" alt=\"New\"></a></td>\n";
    echo "<td colspan=\"2\">" . _("Create a new article") . "</td>\n";
    echo "</tr>\n";
Example #2
0
     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') {
                 continue;
             }
             $connection = $user->getConnection($id);
             if ($connection) {
                 $rs = $connection->postArticle($article);