summaryrefslogtreecommitdiff
path: root/htdocs
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-05-24 17:08:38 -0700
committerJesse Morgan <jesse@jesterpm.net ; true>2011-05-24 17:08:38 -0700
commita39f9512f0efd3ec3e0a31df656e25dd3f824f6d (patch)
tree70e797cc9b1f8978f73799fc0d181e9005859530 /htdocs
parentb41edfdbeb371f3259da1470a5533523939b42a0 (diff)
Working on moderation approve/reject
Diffstat (limited to 'htdocs')
-rw-r--r--htdocs/css/main.css9
-rw-r--r--htdocs/moderate/index.php9
-rw-r--r--htdocs/new-post.php6
-rw-r--r--htdocs/postings.php2
-rw-r--r--htdocs/src/Post.inc.php19
-rw-r--r--htdocs/validate.php22
6 files changed, 54 insertions, 13 deletions
diff --git a/htdocs/css/main.css b/htdocs/css/main.css
index a2cffd3..bc3157c 100644
--- a/htdocs/css/main.css
+++ b/htdocs/css/main.css
@@ -9,7 +9,6 @@ body {
#nav, #buttonblock, #content, #footer {
width: 50%;
margin: 0 auto 0 auto;
- text-transform: uppercase;
}
#nav ul {
@@ -110,3 +109,11 @@ body {
position: relative;
left: 200px;
}
+
+.moderationbox {
+ width: 80%;
+ border: #DDDD00 solid 3px;
+ background: #FFFF55;
+ padding: 0.5em;
+ margin: 1em auto 1em auto;
+}
diff --git a/htdocs/moderate/index.php b/htdocs/moderate/index.php
index 454a514..3c0c9ca 100644
--- a/htdocs/moderate/index.php
+++ b/htdocs/moderate/index.php
@@ -34,11 +34,10 @@ $posts->query();
if ($posts->valid()) {
foreach ($posts as $id => $post) {
- printf("<div class=\"post\"><p><a href=\"preview/%s\">%s</a></p>"
- . "<div class=\"options\"><a href=\"approve/%s\">Approve</a>"
- . " <a href=\"reject/%s\">Reject</a></div></div>",
-
- $id, $post->getName(), $id, $id);
+ printf("<div class=\"post\"><p><a href=\"preview/%s.html\">%s</a></p>"
+ . "%s <a href=\"mailto:%s\">%s</a></div>",
+
+ $id, $post->getName(), $post->getCreated(), $post->getEmail(), $post->getEmail());
}
} else {
diff --git a/htdocs/new-post.php b/htdocs/new-post.php
index 0d1556c..cef238e 100644
--- a/htdocs/new-post.php
+++ b/htdocs/new-post.php
@@ -39,6 +39,10 @@ if (isset($_POST['category'])) {
$error .= "<p>Email addresses must match.</p>";
}
+ if ($_POST['tos'] != '1') {
+ $error .= "<p>You must accept the terms of service.</p>";
+ }
+
if ($error == '') {
$post = new Post();
@@ -97,6 +101,8 @@ function render_form($error="") {
echo "<p><label><input type=\"checkbox\" name=\"tos\" value=\"1\" />"
." I agree to the terms of service.</label></p>";
+ // TODO: Allow picture uploads.
+
echo "<p><input type=\"submit\" value=\"Submit\" /></p></form>";
}
diff --git a/htdocs/postings.php b/htdocs/postings.php
index c6f53d5..e43f24e 100644
--- a/htdocs/postings.php
+++ b/htdocs/postings.php
@@ -28,7 +28,7 @@ if (!is_numeric($id)) {
// Get the post.
$post = Post::getById($id);
-if (!$post) {
+if (!$post or $post->getStage() != 'approved') {
errorNotFound();
}
diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php
index cfd7d07..820ca97 100644
--- a/htdocs/src/Post.inc.php
+++ b/htdocs/src/Post.inc.php
@@ -46,10 +46,11 @@ class Post {
$row = $db->fetchAssocRow($query);
if ($row) {
- $user = new Post();
- $user->info = $row;
+ $post = new Post();
+ $post->info = $row;
+ $post->indatabase = true;
- return $user;
+ return $post;
} else {
return false;
@@ -62,6 +63,9 @@ class Post {
// Cleanup Info
foreach ($this->info as $key=>$value) $info[$key] = addslashes($value);
+ // Remove artifical fields.
+ unset($info['createdts']);
+
// Save or create?
if ($this->indatabase) {
return $db->update('post', $info, "WHERE `id`='". $this->getId() ."'");
@@ -70,6 +74,7 @@ class Post {
// Creating... set special fields.
$info['stage'] = 'verification';
$info['secretid'] = uniqid();
+ $info['created'] = date('Y-m-d H:i:s');
$ret = $db->insert('post', $info);
@@ -112,11 +117,15 @@ class Post {
}
public function approve() {
- $this->info['stage'] = 'approved';
+ if ($this->getStage() == 'moderation') {
+ $this->info['stage'] = 'approved';
+ }
}
public function verify() {
- $this->info['stage'] = 'verify';
+ if ($this->getStage() == 'verification') {
+ $this->info['stage'] = 'moderation';
+ }
}
public function getCreated() {
diff --git a/htdocs/validate.php b/htdocs/validate.php
index 272640b..d69510b 100644
--- a/htdocs/validate.php
+++ b/htdocs/validate.php
@@ -14,6 +14,26 @@ require_once "src/header.inc.php";
echo "<h2>Email Verification</h2>";
-if (isset($_POST
+if (isset($_GET['id'])) {
+ $id = addslashes($_GET['id']);
+ $post = Post::getBySecretId($id);
+
+ if ($post) {
+ $post->verify();
+ $post->save();
+
+ echo "<p>Your email address has been validated. Your post will be listed"
+ . " as soon as we approve the content. You will recieve an email when"
+ . " the post is approved.</p>";
+
+ } else {
+ echo "<div class=\"error\">Invalid validation ID provided.</div>";
+ }
+
+} else {
+ echo "<div class=\"error\">No validation ID provided.</div>";
+}
+
+require_once "src/footer.inc.php";
?>