123 lines
4.7 KiB
Plaintext
123 lines
4.7 KiB
Plaintext
<?php
|
|
|
|
function queue_menu() {
|
|
return array("<A HREF=\"module.php?mod=queue\">". t("moderation queue") ."</A> (<FONT COLOR=\"red\">". queue_count() ."</FONT>)");
|
|
}
|
|
|
|
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]), array(status));
|
|
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]), array(status));
|
|
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]), array(status));
|
|
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 .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
|
|
$content .= " <TR><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=queue&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\">". queue_score($node->nid) ."</TD></TR>\n";
|
|
else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&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=queue&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 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:") ." \"<A HREF=\"node.php?id=$n->nid\">". check_output($n->title) ."</A>\".";
|
|
}
|
|
|
|
if ($node->log) {
|
|
$output .= " ". t("The log message to accompany this submission is given below:") ."<P><I>". check_output($node->log, 1) ."</I></P>";
|
|
}
|
|
|
|
// moderation form:
|
|
$output .= "<FORM ACTION=\"module.php?mod=queue\" METHOD=\"post\">\n";
|
|
foreach ($queue_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);
|
|
$theme->box(t("Moderate"), $output);
|
|
$theme->footer();
|
|
}
|
|
}
|
|
|
|
function queue_page() {
|
|
global $id, $op, $theme, $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;
|
|
}
|
|
}
|
|
else {
|
|
$theme->header();
|
|
$theme->box(t("Moderation queue"), notice_account());
|
|
$theme->footer();
|
|
}
|
|
}
|
|
|
|
?>
|