Newer
Older
// $Id$
case 'admin/modules#description':
return t("Enables content to be moderated by the community.");
case 'admin/settings/queue':
return t("The queue provides a way for your users to vote on submitted content. This is called <strong>moderation</strong>. Users can moderate a post up (give it a point), or down (subtract a point). The settings below give you control over how many points are required for the status of a post to be automatically changed. See individual items for details.");
Dries Buytaert
committed
function queue_settings() {
$post_and_expire = drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100));
$dump = drupal_map_assoc(array(-1, -2, -3, -4, -5, -6, -7, -8, -8, -10, -11, -12, -13, -14, -15, -20, -25, -30));
$output .= form_select(t('Post threshold'), 'queue_threshold_post', variable_get('queue_threshold_post', 4), $post_and_expire, t('When a post gets this number of moderation points, it is <strong>promoted to the front page</strong> automatically.'));
$output .= form_select(t('Dump threshold'), 'queue_threshold_dump', variable_get('queue_threshold_dump', -2), $dump, t('When a post drops below this number of points, its status is changed to <strong>unpublished</strong>.'));
$output .= form_select(t('Expiration threshold'), 'queue_threshold_expire', variable_get('queue_threshold_expire', 8), $post_and_expire, t('When a post gets this number of points, its status is changed to <strong>unpublished</strong>.'));
$output .= form_item(t('Show comments'), form_checkbox(t('Enabled'), 'queue_show_comments', 1, variable_get('queue_show_comments', 1)), t('Tick the box to show comments below the moderation form.'));
function queue_menu($type) {
$items = array();
$items[] = array('path' => 'queue', 'title' => t('submission queue'),
'callback' => 'queue_page',
'access' => user_access('access submission queue'),
'weight' => 1);
return $items;
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 = %d", $node->nid);
$terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
foreach ($terms as $term) {
$node->taxonomy[] = $term->tid;
}
$node->moderate = 0;
$node->promote = 1;
node_save($node);
watchdog('special', t('moderation: approved "%node-title"', array('%node-title' => $node->title)));
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('moderation: declined "%node-title" (rollback)', array('%node-title' => $node->title)));
$node->moderate = 0;
$node->status = 0;
node_save($node);
watchdog('special', t('moderation: declined "%node-title"', array('%node-title' => $node->title)));
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('moderation: expired "%node-title" (rollback)', array('%node-title' => $node->title)));
$node->moderate = 0;
$node->status = 0;
node_save($node);
watchdog('special', t('moderation: expired "%node-title"', array('%node-title' => $node->title)));
/**
* Display a page listing the nodes in the submission queue.
*/
$header = array(array('data' => t('subject')), array('data' => t('author')), array('data' => t('type')), array('data' => t('score')));
$sresult = pager_query('SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.moderate = 1', 10, 0);
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => queue_score($node->nid), 'class' => 'score'));
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => l(t('vote'), 'queue/', $node->nid), 'class' => 'score'));
if ($pager = theme('pager', NULL, 10, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 4));
$output = '<div id="queue">';
$output .= theme('table', $header, $rows);
$output .= '</div>';
/**
* Display a queued node along with voting options for it.
*/
// An associative array with the possible voting options.
$votes = array('+ 0' => t('neutral (+0)'), '+ 1' => t('post it (+1)'), '- 1' => t('dump it (-1)'));
// Load the node from the database.
$node = node_load(array('nid' => $nid, 'moderate' => 1));
if ($node) {
if ($user->uid != $node->uid && !field_get($node->users, $user->uid)) {
if ($op == t('Vote') && $votes[$edit['vote']]) {
// If it is a valid vote, record it.
// Display some explanation or voting guidelines:
$output .= '<p>'. t('When new content is submitted, it goes into the submission queue. Registered users with the appropriate permission can access this queue and vote whether they think the content should be approved or not. When enough people vote to approve the content, it is displayed on the front page. On the other hand, if enough people vote to drop it, the content will disappear.') .'</p>';
// Display a voting form:
$output .= form_select(t('Your vote'), 'vote', '', $votes);
$output .= form_hidden('id', $node->nid);
$output .= form_submit(t('Vote'));
if ($node->comment && variable_get('queue_show_comments', 1)) {
$output .= module_invoke('comment', 'render', $node);
}
}
/**
* Menu callback; displays the queue management page.
*/
function queue_page($nid = 0) {
if ($nid) {
queue_view($nid);
/**
* Implementation of hook_block().
*/
function queue_block($op = 'list', $delta = 0) {
return $blocks;
}
else {
if (user_access('access submission queue') && (arg(0) == 'queue') || arg(0) == 'node') {
if (($user->uid == $node->uid || field_get($node->users, $user->uid)) && $node->moderate == 1) {
$data = explode('=', $vote);
$account = user_load(array('uid' => $data[0]));
$output .= format_name($account) ." voted \"$data[1]\".<br />";
$block['subject'] = t('Moderation results');
$block['content'] = $output ? $output : t('This node has not yet been moderated.');
}
}
return $block;
}
/**
* Implementation of hook_nodeapi().
*/
function queue_nodeapi(&$node, $op) {
switch ($op) {
case 'fields':
return array('score', 'users', 'votes');
case 'validate':
if ($node->nid && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
$node->users = '';
}
break;
case 'insert':
case 'update':
Dries Buytaert
committed
drupal_set_message(t('the post is queued for approval. You can check the votes in the <a href="%queue">submission queue</a>.', array('%queue' => url('queue'))));
}
else if ($node->moderate) {
Dries Buytaert
committed
drupal_set_message(t('the post is queued for approval. The editors will decide whether it should be published.'));
Dries Buytaert
committed
drupal_set_message(t('the post is published.'));
}
break;
}