queue_vote

Versions
4.6
queue_vote($node, $vote)

▾ 1 function calls queue_vote()

queue_view in modules/queue.module
Display a queued node along with voting options for it.

Code

modules/queue.module, line 65

<?php
function queue_vote($node, $vote) {
  global $user;

  if (!isset($node->voters[$user->uid])) {
    db_query("INSERT INTO {queue} (nid, uid, vote) VALUES (%d, %d, %d)", $node->nid, $user->uid, $vote);

    $terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
    foreach ($terms as $term) {
      $node->taxonomy[] = $term->tid;
    }

    if (variable_get('queue_threshold_post', 4) <= $node->score) {
      $node->moderate = 0;
      $node->promote = 1;
      node_save($node);
      watchdog('content', t('Moderation: approved %title.', array('%title' => theme('placeholder', $node->title))));
      drupal_set_message(t('The post is promoted.'));
    }
    else if (variable_get('queue_threshold_dump', -2) >= $node->score) {
      if ($node->revisions) {
        node_revision_rollback($node, end(node_revision_list($node)));
        watchdog('content', t('Moderation: declined %title (rollback).', array('%title' => theme('placeholder', $node->title))));
        drupal_set_message(t('The post has been declined and the previous version has been restored.'));
      }
      else {
        $node->moderate = 0;
        $node->status = 0;
        node_save($node);
        watchdog('content', t('Moderation: declined %title.', array('%title' => theme('placeholder', $node->title))));
        drupal_set_message(t('The post has been declined.'));
      }
    }
    else if (variable_get('queue_threshold_expire', 8) <= $node->votes) {
      if ($node->revisions) {
        node_revision_rollback($node, end(node_revision_list($node)));
        watchdog('content', t('Moderation: expired %title (rollback).', array('%title' => theme('placeholder', $node->title))));
        drupal_set_message(t('The post has expired and the previous version has been restored.'));
      }
      else {
        $node->moderate = 0;
        $node->status = 0;
        node_save($node);
        watchdog('content', t('Moderation: expired %title.', array('%title' => theme('placeholder', $node->title))));
        drupal_set_message(t('The post has expired.'));
      }
    }

    // Reload the updated node from the database:
    $node = node_load(array('nid' => $node->nid), NULL, TRUE);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.