From 18a8041cac4ef0e29b5afe0176c78cea5c9f20dd Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 2 Jun 2011 18:21:43 -0700 Subject: Changed to soft deletion and added 404 pages. --- design/database.sql | 3 ++- htdocs/deletepost.php | 10 ++++++++-- htdocs/new-post.php | 4 ++-- htdocs/page.php | 10 ++++++++-- htdocs/postings.php | 10 ++++++++-- htdocs/src/Post.inc.php | 12 +++--------- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/design/database.sql b/design/database.sql index caecbeb..06b607c 100644 --- a/design/database.sql +++ b/design/database.sql @@ -54,7 +54,8 @@ CREATE TABLE post ( stage ENUM('verification', 'moderation', 'approved', - 'rejected') NOT NULL DEFAULT 'verification', + 'rejected', + 'deleted') NOT NULL DEFAULT 'verification', PRIMARY KEY(id), UNIQUE KEY(secretid) diff --git a/htdocs/deletepost.php b/htdocs/deletepost.php index 7ebec19..50d35c5 100644 --- a/htdocs/deletepost.php +++ b/htdocs/deletepost.php @@ -48,8 +48,14 @@ if (isset($_GET['confirmed'])) { require_once "src/footer.inc.php"; function errorNotFound() { - // TODO: Better 404 error - echo "404"; + // Get the 404 page + $page = Page::getByUrl('404'); + if ($page) { + echo $page->getContent(); + } else { + echo "Error: Page not found."; + } + require_once "src/footer.inc.php"; exit; } diff --git a/htdocs/new-post.php b/htdocs/new-post.php index d463d1a..273e864 100644 --- a/htdocs/new-post.php +++ b/htdocs/new-post.php @@ -22,9 +22,9 @@ echo "

New Posting

"; * 2) ToS * 3) Title, Desc, Location, email * 4) Images - * 5) Notify about email + * 5) Source + * 6) Notify about email * - * TODO: Set the source of the post. */ $stage = 'category'; diff --git a/htdocs/page.php b/htdocs/page.php index e843229..2ccc248 100644 --- a/htdocs/page.php +++ b/htdocs/page.php @@ -35,8 +35,14 @@ echo $page->getContent(); require_once "src/footer.inc.php"; function errorNotFound() { - // TODO: Better 404 error - echo "404"; + // Get the 404 page + $page = Page::getByUrl('404'); + if ($page) { + echo $page->getContent(); + } else { + echo "Error: Page not found."; + } + require_once "src/footer.inc.php"; exit; } diff --git a/htdocs/postings.php b/htdocs/postings.php index ee178cb..a40cfb7 100644 --- a/htdocs/postings.php +++ b/htdocs/postings.php @@ -66,8 +66,14 @@ foreach ($post->getImages() as $imgid) { require_once "src/footer.inc.php"; function errorNotFound() { - // TODO: Better 404 error - echo "404"; + // Get the 404 page + $page = Page::getByUrl('404'); + if ($page) { + echo $page->getContent(); + } else { + echo "Error: Page not found."; + } + require_once "src/footer.inc.php"; exit; } diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php index 4f5e246..e36884b 100644 --- a/htdocs/src/Post.inc.php +++ b/htdocs/src/Post.inc.php @@ -110,15 +110,9 @@ class Post { } public function delete() { - $db = getDatabase(); - - // Delete Images - $db->delete('image', 'post_id=' . $this->getId()); - - // Delete Post - $db->delete('post', 'id=' . $this->getId()); - - $this->indatabase = false; + // Rather than deleting the post, archive it. + $this->info['stage'] = 'deleted'; + $this->save(); } public function getId() { -- cgit v1.2.3