You are here

function vud_node_tracker in Vote Up/Down 6.2

Same name and namespace in other branches
  1. 6.3 vud_node/vud_node.module \vud_node_tracker()
  2. 7 vud_node/vud_node.module \vud_node_tracker()

Menu callback; display all votes for a node.

1 string reference to 'vud_node_tracker'
vud_node_menu in vud_node/vud_node.module
Implementation of hook_menu().

File

vud_node/vud_node.module, line 215
Adds a voting widget to nodes.

Code

function vud_node_tracker() {
  if ($node = menu_get_object()) {
    $header = array(
      array(
        'data' => t('User'),
      ),
      array(
        'data' => t('Vote'),
      ),
      array(
        'data' => t('Date'),
      ),
    );
    $tag = variable_get('vud_tag', 'vote');
    $criteria = array(
      'content_type' => 'node',
      'content_id' => $node->nid,
      'tag' => $tag,
    );
    $votes = votingapi_select_votes($criteria);
    $rows[] = array();
    foreach ($votes as $vote) {
      $account = user_load($vote['uid']);
      $rows[] = array(
        theme('username', $account),
        $vote['value'],
        array(
          'data' => format_date($vote['timestamp'], 'small'),
          'class' => 'nowrap',
        ),
      );
    }
    drupal_set_title(check_plain($node->title));
    $output = theme('table', $header, $rows);
    $output .= theme('pager', NULL, 30);
    return $output;
  }
  else {
    drupal_not_found();
  }
}