". t("moderation queue") ." (". queue_count() .")"); } function queue_count() { global $status; $result = db_query("SELECT COUNT(nid) FROM node WHERE status = '$status[queued]'"); return ($result) ? db_result($result, 0) : 0; } function queue_score($id) { $result = db_query("SELECT score FROM node WHERE nid = '$id'"); return ($result) ? db_result($result, 0) : 0; } function queue_vote($id, $vote) { global $status, $user; if (!user_get($user, "history", "n$id")) { // Update submission's score- and votes-field: db_query("UPDATE node SET score = score $vote, votes = votes + 1 WHERE nid = $id"); // Update user's history record: $user = user_set($user, "history", "n$id", $vote); if ($node = node_get_object(nid, $id)) { if (variable_get("post_threshold", 4, $node) <= $node->score) { node_save(array(nid => $id, status => $status[posted])); watchdog("message", "node: posted '$node->title' - moderation"); } else if (variable_get("dump_threshold", -2, $node) >= $node->score) { node_save(array(nid => $id, status => $status[dumped])); watchdog("message", "node: dumped '$node->title' - moderation"); } else if (variable_get("expire_threshold", 8, $node) <= $node->votes) { node_save(array(nid => $id, status => $status[expired])); watchdog("message", "node: expired '$node->title' - moderation"); } } } } function queue_overview() { global $status, $theme, $user; $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'"); $content .= "\n"; $content .= " \n"; while ($node = db_fetch_object($result)) { if ($user->id == $node->author || user_get($user, "history", "n$node->nid")) $content .= " \n"; else $content .= " \n"; } $content .= "
". t("Subject") ."". t("Author") ."". t("Type") ."". t("Score") ."
nid\">". check_output($node->title) ."". format_username($node->userid) ."". check_output($node->type) ."". queue_score($node->nid) ."
nid\">". check_output($node->title) ."". format_username($node->userid) ."". check_output($node->type) ."nid\">". t("vote") ."
\n"; $theme->header(); $theme->box(t("Moderation queue"), $content); $theme->footer(); } function queue_node($id) { global $theme, $user; $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 { $queue_votes = array("neutral (+0)" => "+ 0", "post it (+1)" => "+ 1", "dump it (-1)" => "- 1"); // The keys of this associative array are displayed in each submission's selection box whereas the corresponding values represent the mathematical calculation to be performed to update a comment's value. if ($n = node_get_object("nid", $node->pid)) { $output .= " ". t("The above node is a proposed update of an existing node:") ." \"nid\">". check_output($n->title) ."\"."; } if ($node->log) { $output .= " ". t("The log message to accompany this submission is given below:") ."

". check_output($node->log, 1) ."

"; } // moderation form: $output .= "
\n"; foreach ($queue_votes as $key=>$value) $options .= " \n"; $output .= "\n"; $output .= "nid\">\n"; $output .= "\n"; $output .= "
\n"; $theme->header(); node_view($node); $theme->box(t("Moderate"), $output); $theme->footer(); } } function queue_page() { global $id, $op, $user, $vote; if ($user->id) { switch($op) { case "Vote"; queue_vote(check_input($id), check_input($vote)); // fall through: case "view": queue_node(check_input($id)); break; default: queue_overview(); break; } } } ?>