summaryrefslogtreecommitdiff
path: root/htdocs/moderate/moderate.php
blob: 29294ec49efbd5878812227c9ead9a1f093f18fa (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
<?php

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

require_once('../src/base.inc.php');

if (!isset($_SESSION['currentUser'])) {
    header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php');
    exit();
}

// If we have a valid id.
if (isset($_GET['id']) and is_numeric($_GET['id'])) {

    // Get the post.
    $post = Post::getById($_GET['id']);

    if ($post) {
        // Accept or Reject.
        if (isset($_GET['action'])) {
            switch ($_GET['action']) {
                case 'approve':
                    $post->approve();
                    break;

                case 'reject':
                    $post->reject();
                    break;

                case 'delete':
                    if ($_SESSION['currentUser']->isAdmin()) {
                        $post->delete();
                    }
                    break;
            }

            $post->save();
        }
    }
}

// Redirect back to the moderation index.
header('Location: ' . $CONFIG['urlroot'] . '/moderate');

?>