summaryrefslogtreecommitdiff
path: root/htdocs/moderate/moderate.php
blob: 0d3a67de83c3868afd5c985f51909ed70e9f00dc (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
<?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;
            }

            $post->save();
        }
    }
}

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

?>