format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => t("Never")); $output .= form_select(t("Discard entries older than"), "queue_clear", variable_get("queue_clear", 604800), $period, t("The time nodes should be kept in the submission queue. Older entries will be automatically discarded. Requires crontab.")); return $output; } function queue_perm() { return array("access submission queue"); } function queue_link($type) { if ($type == "menu" && user_access("access submission queue")) { $links[] = "". t("submission queue") ." (". queue_count() .")"; } return $links ? $links : array(); } function queue_cron() { // TODO: use 'created' or 'changed' ? // db_query("UPDATE node SET status = 0 WHERE moderate = 1 AND ". time() ." - timestamp > ". variable_get("queue_clear", 604800)); } function queue_count() { $result = db_query("SELECT COUNT(nid) FROM node WHERE moderate = 1"); 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 $user; if ($node = node_load(array(nid => $id))) { if (!field_get($node->users, $user->uid)) { // Update submission's score- and votes-field: db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = $id"); $node = node_load(array(nid => $id, type => $node->type)); if (variable_get($node->type ."_post", 4) <= $node->score) { node_save($node, array("nid", "status" => 1, "moderate" => 0)); watchdog("special", "node: posted '$node->title' - moderation"); } else if (variable_get($node->type ."_dump", -2) >= $node->score) { node_save($node, array("nid", "status" => 1, "moderate" => 0)); watchdog("special", "node: dumped '$node->title' - moderation"); } else if (variable_get($node->type ."_expire", 8) <= $node->votes) { node_save($node, array("nid", "status" => 0, "moderate" => 0)); watchdog("special", "node: expired '$node->title' - moderation"); } } } } function queue_overview() { global $theme, $user; $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.moderate = 1"); $content .= ""; $content .= " "; while ($node = db_fetch_object($result)) { if ($user->uid == $node->uid || field_get($node->users, $user->uid)) $content .= " "; else $content .= " "; } $content .= "
". t("Subject") ."". t("Author") ."". t("Type") ."". t("Score") ."
nid\">". check_output($node->title) ."". format_name($node) ."". check_output($node->type) ."". queue_score($node->nid) ."
nid\">". check_output($node->title) ."". format_name($node) ."". check_output($node->type) ."nid\">". t("vote") ."
"; $theme->header(); $theme->box(t("Moderation queue"), $content); $theme->footer(); } function queue_view($id) { global $theme, $user; $node = node_load(array(nid => $id)); if ($user->uid == $node->uid || field_get($node->users, $user->uid)) { drupal_goto("node.php?id=$node->nid"); } else { /* ** 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. */ $queue_votes = array("neutral (+0)" => "+ 0", "post it (+1)" => "+ 1", "dump it (-1)" => "- 1"); // TODO: this is where the upcoming versioning system should come in if ($n = node_load(array("nid" => $node->pid))) { $output .= " ". t("The above node is a proposed update of an existing node:") ." \"nid\">". check_output($n->title) ."\"."; } // TODO: this is where the upcoming versioning system should come in if ($node->log) { $output .= " ". t("The log message to accompany this submission is given below:") ."

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

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