summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-03-24 16:31:17 +0000
committerDries Buytaert <dries@buytaert.net>2001-03-24 16:31:17 +0000
commit5586d58c0f21284c0060838a630e7c9b40aa53ee (patch)
tree4d360be13bea12d1b7f23f7c3b33edd95b4aa731 /modules
parentde7e1fb66aea6cced3349f0bebc020b3485cdd7c (diff)
downloadbrdo-5586d58c0f21284c0060838a630e7c9b40aa53ee.tar.gz
brdo-5586d58c0f21284c0060838a630e7c9b40aa53ee.tar.bz2
- the "submission.module" is going to be replaced by a "moderation.module"
Diffstat (limited to 'modules')
-rw-r--r--modules/moderation.module112
-rw-r--r--modules/submission.module130
2 files changed, 112 insertions, 130 deletions
diff --git a/modules/moderation.module b/modules/moderation.module
new file mode 100644
index 000000000..3d0b0f4c8
--- /dev/null
+++ b/modules/moderation.module
@@ -0,0 +1,112 @@
+<?php
+
+$module = array("menu" => "moderation_menu",
+ "page" => "moderation_page");
+
+include_once "includes/common.inc";
+
+function moderation_menu() {
+ return array("<A HREF=\"module.php?mod=moderation\">". t("moderation queue") ."</A> (<FONT COLOR=\"red\">". moderation_count() ."</FONT>)");
+}
+
+function moderation_count() {
+ $result = db_query("SELECT COUNT(nid) FROM nodes WHERE status = 1");
+ return ($result) ? db_result($result, 0) : 0;
+}
+
+function moderation_score($id) {
+ $result = db_query("SELECT score FROM nodes WHERE nid = '$id'");
+ return ($result) ? db_result($result, 0) : 0;
+}
+
+function moderation_vote($id, $vote) {
+ global $user;
+
+ if (!user_get($user, "history", "n$id")) {
+ // Update submission's score- and votes-field:
+ db_query("UPDATE nodes SET score = score $vote, votes = votes + 1 WHERE nid = $id");
+
+ // Update user's history record:
+ $user = user_set($user, "history", "n$id", $vote);
+
+ $result = db_query("SELECT * FROM nodes WHERE nid = $id");
+ if ($node = db_fetch_object($result)) {
+ if (node_post_threshold($node) <= $node->score) {
+ db_query("UPDATE nodes SET status = 2, timestamp = '". time() ."' WHERE nid = $id");
+ watchdog("message", "posted node '$node->subject'");
+ }
+ else if (node_dump_threshold($node) >= $node->score) {
+ db_query("UPDATE nodes SET status = 0, timestamp = '". time() ."' WHERE nid = $id");
+ watchdog("message", "dumped node '$node->subject'");
+ }
+ else if (node_timout_threshold($node) <= $node->votes) {
+ db_query("UPDATE nodes SET status = 0, timestamp = '". time() ."' WHERE nid = $id");
+ watchdog("message", "expired node '$node->subject'");
+ }
+ }
+ }
+}
+
+function moderation_overview() {
+ global $theme, $user;
+
+ $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.status = 1");
+
+ $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
+ $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
+ while ($node = db_fetch_object($result)) {
+ if ($user->id == $node->author || user_get($user, "history", "n$node->nid")) $content .= " <TR><TD><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". moderation_score($node->nid) ."</TD></TR>\n";
+ else $content .= " <TR><TD><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
+ }
+ $content .= "</TABLE>\n";
+
+ $theme->header();
+ $theme->box(t("Moderation queue"), $content);
+ $theme->footer();
+}
+
+function moderation_node($id) {
+ global $theme, $user, $moderation_votes;
+
+ $node = node_get_object(nid, $id);
+
+ if ($user->id == $node->author || user_get($user, "history", "n$node->nid")) {
+ header("Location: node.php?id=$node->nid");
+ }
+ else {
+ // moderation form:
+ $output .= "<FORM ACTION=\"module.php?mod=moderation\" METHOD=\"post\">\n";
+ foreach ($moderation_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
+ $output .= "<SELECT NAME=\"vote\">$options</SELECT>\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$node->nid\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n";
+ $output .= "</FORM>\n";
+
+ $theme->header();
+ node_view($node, 1);
+ $theme->box(t("Moderate"), $output);
+ $theme->footer();
+ }
+}
+
+function moderation_page() {
+ global $id, $op, $user, $vote;
+
+ if ($user->id) {
+ $user = user_load($user->userid);
+
+ switch($op) {
+ case "Vote";
+ moderation_vote(check_input($id), check_input($vote));
+ // fall through:
+ case "view":
+ moderation_node(check_input($id));
+ break;
+ default:
+ moderation_overview();
+ break;
+ }
+ }
+}
+
+?>
diff --git a/modules/submission.module b/modules/submission.module
deleted file mode 100644
index c1e02a761..000000000
--- a/modules/submission.module
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-$module = array("menu" => "submission_menu",
- "page" => "submission_page");
-
-include_once "includes/common.inc";
-
-function submission_menu() {
- return array("<A HREF=\"module.php?mod=submission\">". t("submission queue") ."</A> (<FONT COLOR=\"red\">". submission_count() ."</FONT>)");
-}
-
-function submission_count() {
- $result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1");
- return ($result) ? db_result($result, 0) : 0;
-}
-
-function submission_score($id) {
- $result = db_query("SELECT score FROM stories WHERE id = '$id'");
- return ($result) ? db_result($result, 0) : 0;
-}
-
-function submission_vote($id, $vote, $comment) {
- global $user;
-
- if (!user_get($user, "history", "s$id")) {
- // Update submission's score- and votes-field:
- db_query("UPDATE stories SET score = score $vote, votes = votes + 1 WHERE id = $id");
-
- // Update the comments (if required):
- if ($comment) {
- db_query("INSERT INTO comments (lid, link, author, subject, comment, hostname, timestamp, score) VALUES($id, 'story', $user->id, '". substr($comment, 0, 29) ." ...', '$comment', '". getenv("REMOTE_ADDR") ."', '". time() ."', '1')");
- watchdog("comment", "moderation: added comment with subject '$subject'");
- }
-
- // Update user's history record:
- $user = user_set($user, "history", "s$id", $vote);
-
- // Update story table (if required):
- $result = db_query("SELECT * FROM stories WHERE id = $id");
- if ($submission = db_fetch_object($result)) {
- if (section_post_threshold($submission->section) <= $submission->score) {
- db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id");
- watchdog("message", "posted story '$submission->subject'");
- }
- else if (section_dump_threshold($submission->section) >= $submission->score) {
- db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
- watchdog("message", "dumped story '$submission->subject'");
- }
- else if (section_timout_threshold($submission->section) <= $submission->votes) {
- db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
- watchdog("message", "expired story '$submission->subject'");
- }
- }
- }
-}
-
-function submission_page_main() {
- global $theme, $user;
-
- // Perform query:
- $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status = 1 ORDER BY s.id");
-
- $content .= "<P>". t("Anyone who happens by, and has some news or some thoughts they'd like to share, can submit new content for consideration. After someone has submitted something, their story is added to a queue. All registered users can access this list of pending stories, that is, stories that have been submitted, but do not yet appear on the public front page. Those registered users can vote whether they think the story should be posted or not. When enough people vote to post a story, the story is pushed over the threshold and up it goes on the public page. On the other hand, when too many people voted to drop a story, the story will get trashed."). "</P>";
- $content .= "<P>". t("Basically, this means that you, the community, are truly the editors of this site as you have the final decision on the content of this site. It's you judging the overall quality of a story. But remember, vote on whether the story is interesting, not on whether you agree with it or not. If the story goes up, you can disagree all you want, but don't vote `no' because you think the ideas expressed are wrong. Instead, vote `no' when you think the story is plain boring.") ."</P>";
- $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
- $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Section") ."</TH><TH>". t("Date") ."</TH><TH>". t("Author") ."</TH><TH>". t("Score") ."</TH></TR>\n";
- while ($submission = db_fetch_object($result)) {
- if ($user->id == $submission->author || user_get($user, "history", "s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"module.php?mod=submission&op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n";
- else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"module.php?mod=submission&op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=submission&op=view&id=$submission->id\">". t("vote") ."</A></TD></TR>\n";
- }
- $content .= "</TABLE>\n";
-
- $theme->header();
- $theme->box(t("Open submission queue - Pending stories"), $content);
- $theme->footer();
-}
-
-function submission_display_item($id) {
- global $theme, $user, $submission_votes;
-
- $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id");
- $submission = db_fetch_object($result);
-
- if ($user->id == $submission->author || user_get($user, "history", "s$submission->id")) {
- header("Location: story.php?id=$submission->id");
- }
- else {
- $output .= "<FORM ACTION=\"module.php?mod=submission\" METHOD=\"post\">\n";
- $output .= "<P>\n";
- $output .= " <B>Vote:</B><BR>\n";
- $output .= " <SELECT NAME=\"vote\">\n";
- foreach ($submission_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
- $output .= " </SELECT>\n";
- $output .= "</P>\n";
- $output .= "<P>\n";
- $output .= " <B>Comment:</B><BR>\n";
- $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"7\" NAME=\"comment\"></TEXTAREA>\n";
- $output .= "</P>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$submission->id\">\n";
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n";
- $output .= "</FORM>\n";
-
- $theme->header();
- $theme->story($submission, "[ <A HREF=\"module.php?mod=submission\"><FONT COLOR=\"$theme->link\">back</FONT></A> ]");
- $theme->box(t("Moderate story"), $output);
- $theme->footer();
- }
-}
-
-function submission_page() {
- global $comment, $id, $op, $user, $vote;
-
- if ($user->id) {
- $user = user_load($user->userid);
-
- switch($op) {
- case "view":
- submission_display_item(check_input($id));
- break;
- case "Vote";
- submission_vote(check_input($id), check_input($vote), check_input($comment));
- // fall through
- default:
- submission_page_main();
- break;
- }
- }
-}
-
-?>