summaryrefslogtreecommitdiff
path: root/htdocs/postings.php
blob: 0440ab02eac64cf68942a35ec1bc1108acec7193 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php

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

require_once "src/base.inc.php";

// Check if we need to login first...
if (isset($_GET['moderate']) and !isset($_SESSION['currentUser'])) {
    header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php');
    exit();
}

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($_SESSION['currentUser']) and $post->getStage() != 'approved')) {
    errorNotFound();
}

if (isset($_SESSION['currentUser'])) {

    if ($post->getStage() != 'approved') {
        // Post waiting for approval...
        echo "<div class=\"moderationbox\">You are moderating this post: ";
        printf("<a href=\"../moderate/moderate.php?id=%s&action=approve\">approve</a> "
            . " or <a href=\"../moderate/moderate.php?id=%s&action=reject\">reject</a>."
            , $post->getid(), $post->getid());

        // Print Source information
        printf("<p>This post was posted by %s from %s.</p>",
            $post->getEmail(), $post->getSourceName());

        echo "<p><a href=\"../moderate/index.php\">return to moderation</a></p>";
        echo "</div>";


    } else {
        // Post already approved
        echo "<div class=\"moderationbox\">Administrative options:<br />";
        
        printf("<a href=\"../moderate/moderate.php?id=%s&action=delete\">delete post</a><br />"
            . "<a href=\"../moderate/moderate.php?id=%s&action=reject\">reject post</a>",
            $post->getid(), $post->getid());

        // Print source info.
        printf("<p>This post was posted by %s from %s.</p>",
            $post->getEmail(), $post->getSourceName());
        
        echo "</div>";
    }

}


// Display the post.

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

if ($post->getPrice() != 0) {
    echo ' - $' . $post->getPrice();
}

echo "</h2>";

echo "<p>Category: " . $post->getCategory()->getName() . "</p>";
echo "<p>Date: ". date('r', $post->getTimestamp()) ."</p>";
echo "<p>Email: <a href=\"mailto:". $post->getPublicEmail() ."\">"
    . $post->getPublicEmail() ."</a></p>";
echo "<p>Location: ". $post->getLocation() ."</p>";

echo "<p class=\"desc\">". 
    str_replace("\n", '<br />', $post->getDescription())
    ."</p>";

foreach ($post->getImages() as $imgid) {
    echo "<p><img src=\"". $GLOBALS['CONFIG']['urlroot']
        . "/postimages/$imgid\" /></p>";
}

require_once "src/footer.inc.php";


function errorNotFound() {
    // Get the 404 page
    $page = Page::getByUrl('404');
    if ($page) {
        echo $page->getContent();
    } else {
        echo "Error: Page not found.";
    }
    require_once "src/footer.inc.php";
    exit;
}

?>