". 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 .= "
". 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") ." |
". check_output($node->log, 1) ."
"; } // moderation form: $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; } } } ?>