From a39f9512f0efd3ec3e0a31df656e25dd3f824f6d Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Tue, 24 May 2011 17:08:38 -0700 Subject: Working on moderation approve/reject --- .gitignore | 2 +- htdocs/css/main.css | 9 ++++++++- htdocs/moderate/index.php | 9 ++++----- htdocs/new-post.php | 6 ++++++ htdocs/postings.php | 2 +- htdocs/src/Post.inc.php | 19 ++++++++++++++----- htdocs/validate.php | 22 +++++++++++++++++++++- 7 files changed, 55 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index f88a8a1..478fc35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ **.swp -htdocs/email.log +htdocs/emails.log tags 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("

%s

" - . "
", - - $id, $post->getName(), $id, $id); + printf("

%s

" + . "%s %s
", + + $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 .= "

Email addresses must match.

"; } + if ($_POST['tos'] != '1') { + $error .= "

You must accept the terms of service.

"; + } + if ($error == '') { $post = new Post(); @@ -97,6 +101,8 @@ function render_form($error="") { echo "

"; + // TODO: Allow picture uploads. + echo "

"; } 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 "

Email Verification

"; -if (isset($_POST +if (isset($_GET['id'])) { + $id = addslashes($_GET['id']); + $post = Post::getBySecretId($id); + + if ($post) { + $post->verify(); + $post->save(); + + echo "

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.

"; + + } else { + echo "
Invalid validation ID provided.
"; + } + +} else { + echo "
No validation ID provided.
"; +} + +require_once "src/footer.inc.php"; ?> -- cgit v1.2.3