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 --- htdocs/src/Post.inc.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'htdocs/src') 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() { -- cgit v1.2.3