Display a queued node along with voting options for it.

1 call to queue_view()
queue_page in modules/queue.module
Menu callback; displays the queue management page.

File

modules/queue.module, line 159
Enables content to be moderated by the community.

Code

function queue_view($nid) {
  global $user;
  $op = $_POST['op'];
  $edit = $_POST['edit'];

  // 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 && !isset($node->voters[$user->uid])) {
      if ($op == t('Vote') && $votes[$edit['vote']]) {

        // If it is a valid vote, record it.
        queue_vote($node, $edit['vote']);
        $output = t('Your vote has been recorded.');
      }
      else {

        // 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'));
        $output = form($output);
      }
    }
    $output .= node_view($node);
    $output = theme('box', t('Moderate'), $output);
    if ($node->comment && variable_get('queue_show_comments', 1)) {
      $output .= module_invoke('comment', 'render', $node);
    }
    print theme('page', $output);
  }
  else {
    drupal_not_found();
  }
}