summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htdocs/moderate/moderate.php6
-rw-r--r--htdocs/moderate/src/header.inc.php8
-rw-r--r--htdocs/postings.php35
-rw-r--r--htdocs/src/Post.inc.php6
4 files changed, 39 insertions, 16 deletions
diff --git a/htdocs/moderate/moderate.php b/htdocs/moderate/moderate.php
index 0d3a67d..29294ec 100644
--- a/htdocs/moderate/moderate.php
+++ b/htdocs/moderate/moderate.php
@@ -32,6 +32,12 @@ if (isset($_GET['id']) and is_numeric($_GET['id'])) {
case 'reject':
$post->reject();
break;
+
+ case 'delete':
+ if ($_SESSION['currentUser']->isAdmin()) {
+ $post->delete();
+ }
+ break;
}
$post->save();
diff --git a/htdocs/moderate/src/header.inc.php b/htdocs/moderate/src/header.inc.php
index 901344a..f0abbe1 100644
--- a/htdocs/moderate/src/header.inc.php
+++ b/htdocs/moderate/src/header.inc.php
@@ -6,6 +6,12 @@ if (!isset($_SESSION['currentUser'])) {
exit();
}
+if (isset($_GET['logout'])) {
+ unset($_SESSION['currentUser']);
+ header('Location: ' . buildUrl());
+ exit();
+}
+
?><!DOCTYPE html>
<html>
<head>
@@ -58,7 +64,7 @@ if (!isset($_SESSION['currentUser'])) {
<li><a href="<?= buildUrl('moderate/account.php') ?>">
Account Settings</a></li>
- <li><a href="">Logout</a></li>
+ <li><a href="<?= buildUrl('moderate/?logout') ?>">Logout</a></li>
</ul>
</div>
diff --git a/htdocs/postings.php b/htdocs/postings.php
index a52d939..b275858 100644
--- a/htdocs/postings.php
+++ b/htdocs/postings.php
@@ -28,24 +28,37 @@ if (!is_numeric($id)) {
// Get the post.
$post = Post::getById($id);
-if (!$post or (!isset($_GET['moderate']) and $post->getStage() != 'approved')) {
+if (!$post or (!isset($_SESSION['currentUser']) and $post->getStage() != 'approved')) {
errorNotFound();
}
-if (isset($_GET['moderate'])) {
- if (!isset($_SESSION['currentUser'])) {
- header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php');
- exit();
+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> "
+ . "<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>";
+
+
+ } else {
+ // Post already approved
+ if ($_SESSION['currentUser']->isAdmin()) {
+ 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());
+ echo "</div>";
+ }
}
- 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();
diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php
index d887694..c844830 100644
--- a/htdocs/src/Post.inc.php
+++ b/htdocs/src/Post.inc.php
@@ -168,10 +168,8 @@ class Post {
}
public function approve() {
- if ($this->getStage() == 'moderation') {
- $this->info['stage'] = 'approved';
- $this->sendAcceptance();
- }
+ $this->info['stage'] = 'approved';
+ $this->sendAcceptance();
}
public function verify() {