You are here

function vote_up_down_tracker in Vote Up/Down 6

Same name and namespace in other branches
  1. 5 vote_up_down.module \vote_up_down_tracker()

Menu callback; display all votes for a node.

1 string reference to 'vote_up_down_tracker'
vote_up_down_menu in ./vote_up_down.module
Implementation of hook_menu().

File

./vote_up_down.module, line 466

Code

function vote_up_down_tracker() {
  if ($node = menu_get_object()) {
    $header = array(
      array(
        'data' => t('User'),
      ),
      array(
        'data' => t('Vote'),
      ),
      array(
        'data' => t('Date'),
      ),
    );
    $tag = variable_get('vote_up_down_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(array(
        'uid' => $vote['uid'],
        'status' => 1,
      ));
      $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();
  }
}