summaryrefslogtreecommitdiff
path: root/htdocs/postings.php
blob: 5c3dd5520b066e0d32eee88bfc338b6118375fd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

/* Foursquare Community Site
 * 
 * Copyright (C) 2011 Foursquare Church.
 * 
 * Developers: Jesse Morgan <jmorgan@foursquarestaff.com>
 *
 */

require_once "src/base.inc.php";

require_once "src/header.inc.php";


// Make sure we had a path info
if (!isset($_SERVER['PATH_INFO'])) {
    errorNotFound();
}

// Clean up the id in the path info.
$id = substr($_SERVER['PATH_INFO'], 1, strpos($_SERVER['PATH_INFO'], '.') - 1);

if (!is_numeric($id)) {
    errorNotFound();
}

// Get the post.
$post = Post::getById($id);

if (!$post or (!isset($_GET['moderate']) and $post->getStage() != 'approved')) {
    errorNotFound();
}

if (isset($_GET['moderate'])) {
    if (!isset($_SESSION['currentUser'])) {
        header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php');
        exit();
    }
    echo "<div class=\"moderationbox\">You are moderating this post: ";
    printf("<a href=\"../moderate/moderate.php?id=%s&action=approve\">Approve</a> "
        . "<a href=\"../moderate/moderate.php?id=%s&action=reject\">Reject</a>",
        $post->getId(), $post->getId());
    echo "<p><a href=\"../moderate/index.php\">Return to moderation</a></p>";
    echo "</div>";

}

// Display the post.

echo "<h2>". $post->getName() ."</h2>";

echo "<p>". $post->getDescription() ."</p>";



require_once "src/footer.inc.php";

function errorNotFound() {
    // TODO: Better 404 error
    echo "404";
    exit;
}

?>