From 0c72d673a9056c753503e6b2a8d4fbf3aba75a95 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Wed, 25 May 2011 11:32:49 -0700 Subject: Moderation workflow is.. working --- design/database.sql | 3 +- htdocs/css/main.css | 12 +++++ htdocs/index.php | 2 - htdocs/moderate/admin.css | 95 ++++---------------------------------- htdocs/moderate/index.php | 18 +++----- htdocs/moderate/moderate.php | 45 ++++++++++++++++++ htdocs/moderate/src/footer.inc.php | 1 - htdocs/moderate/src/header.inc.php | 83 ++++++++++++++------------------- htdocs/new-post.php | 26 ++++++++--- htdocs/postings.php | 16 ++++++- htdocs/src/Post.inc.php | 4 ++ htdocs/src/User.inc.php | 4 ++ htdocs/src/header.inc.php | 5 +- 13 files changed, 154 insertions(+), 160 deletions(-) create mode 100644 htdocs/moderate/moderate.php diff --git a/design/database.sql b/design/database.sql index 08bcc54..6bb34da 100644 --- a/design/database.sql +++ b/design/database.sql @@ -52,7 +52,8 @@ CREATE TABLE post ( source_id INTEGER UNSIGNED NOT NULL, stage ENUM('verification', 'moderation', - 'approved') NOT NULL DEFAULT 'verification', + 'approved', + 'rejected') NOT NULL DEFAULT 'verification', PRIMARY KEY(id), UNIQUE KEY(secretid) diff --git a/htdocs/css/main.css b/htdocs/css/main.css index bc3157c..be823b3 100644 --- a/htdocs/css/main.css +++ b/htdocs/css/main.css @@ -117,3 +117,15 @@ body { padding: 0.5em; margin: 1em auto 1em auto; } + +.errorbox { + width: 80%; + border: #DD0000 solid 3px; + background: #FFBBBB; + padding: 0.5em; + margin: 1em 0 1em 0; +} + +.errorbox p { + margin: 0; +} diff --git a/htdocs/index.php b/htdocs/index.php index 6ac32ff..148cfd6 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -21,7 +21,6 @@ $posts->limit(5); $posts->query(); if ($posts->valid()) { - for ($i = 0; $i < 10; $i++) { foreach ($posts as $id => $post) { printf("

%s

" @@ -30,7 +29,6 @@ if ($posts->valid()) { $id, $post->getName(), $post->getLocation(), $post->getAge()); } - } } else { echo "

No recent posts.

"; diff --git a/htdocs/moderate/admin.css b/htdocs/moderate/admin.css index 936c3ec..a1e7ed0 100644 --- a/htdocs/moderate/admin.css +++ b/htdocs/moderate/admin.css @@ -1,99 +1,20 @@ -body { - font-family: "Lucida Grande", "Lucida Sans", "Lucida", sans-serif; - font-size: 0.75em; - line-height: 1.5em; - - margin-left: 10%; - margin-top: 5%; - width: 60%; -} - h1 { - font-size: 4em; - margin-bottom: 1.25em; -} - -a, a:visited { - color: #1070c0; - text-decoration: none; + margin-left: 1em; + margin-bottom: 0; } #content { - width: 75%; + width: auto; padding-left: 3em; - } -#nav { - float: right; +#modnav ul { + margin: 0; + padding: 0; } -#nav ul { - padding-left: 1em; +#modnav ul li { list-style: none; -} - -#search { - float: right; - margin-top: -2em; -} - -#listing { - margin-top: 1.5em; -} - -#listing .header { - background: #555; - padding: 0.75em; - color: white; - font-weight: bold; - font-size: 120%; -} - -#listing .row0, #listing .row1 { - border-top: solid thin #AAA; - padding: 0.75em; -} - -#listing .row0 { -} - -#listing .row1 { -} - -#listing .col0 { display: inline-block; - width: 100px; - text-align: center; -} - - -.element input[type=text], .element input[type=password] { - width: 90%; - padding: .5em; -} - -label { - font-weight: bold; -} - -.element { - margin-bottom: 1.25em; -} - -.buttons { - float: right; - margin-right: 10%; -} - -div.error { - background: #FAA; - border: solid red 2px; - padding: 1.5em; - margin: 2em 0 2em 0; - width: 90%; -} - -p { - margin: 0; + margin-right: 1em; } diff --git a/htdocs/moderate/index.php b/htdocs/moderate/index.php index 3c0c9ca..908c43b 100644 --- a/htdocs/moderate/index.php +++ b/htdocs/moderate/index.php @@ -10,17 +10,10 @@ require_once('../src/base.inc.php'); -if (!isset($_SESSION['currentUser'])) { - header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php'); - exit(); -} - -require_once('header.inc.php'); +require_once('src/header.inc.php'); ?> -

Welcome

- query(); if ($posts->valid()) { foreach ($posts as $id => $post) { - printf("

%s

" + printf("

%s

" . "%s %s
", - $id, $post->getName(), $post->getCreated(), $post->getEmail(), $post->getEmail()); + $GLOBALS['CONFIG']['urlroot'], + $id, $post->getName(), + $post->getCreated(), + $post->getEmail(), $post->getEmail()); } } else { echo "

No posts awaiting approval

"; } -require_once('footer.inc.php'); +require_once('src/footer.inc.php'); ?> diff --git a/htdocs/moderate/moderate.php b/htdocs/moderate/moderate.php new file mode 100644 index 0000000..0d3a67d --- /dev/null +++ b/htdocs/moderate/moderate.php @@ -0,0 +1,45 @@ + + * + */ + +require_once('../src/base.inc.php'); + +if (!isset($_SESSION['currentUser'])) { + header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php'); + exit(); +} + +// If we have a valid id. +if (isset($_GET['id']) and is_numeric($_GET['id'])) { + + // Get the post. + $post = Post::getById($_GET['id']); + + if ($post) { + // Accept or Reject. + if (isset($_GET['action'])) { + switch ($_GET['action']) { + case 'approve': + $post->approve(); + break; + + case 'reject': + $post->reject(); + break; + } + + $post->save(); + } + } +} + +// Redirect back to the moderation index. +header('Location: ' . $CONFIG['urlroot'] . '/moderate'); + +?> diff --git a/htdocs/moderate/src/footer.inc.php b/htdocs/moderate/src/footer.inc.php index 96d3e78..5b85fcc 100644 --- a/htdocs/moderate/src/footer.inc.php +++ b/htdocs/moderate/src/footer.inc.php @@ -1,4 +1,3 @@ -
diff --git a/htdocs/moderate/src/header.inc.php b/htdocs/moderate/src/header.inc.php index 4310009..fc8a06f 100644 --- a/htdocs/moderate/src/header.inc.php +++ b/htdocs/moderate/src/header.inc.php @@ -1,64 +1,51 @@ fetchAssocRow($query); - - if ($result) { - $SESSION['currentUser'] = $result; - } - - } +// Require Authentication +if (!isset($_SESSION['currentUser'])) { + header('Location: ' . $CONFIG['urlroot'].'/moderate/login.php'); + exit(); } ?> - - - - + + + -

Foursquare Admin Panel

-