You are here

function vote_up_down_tracker in Vote Up/Down 5

Same name and namespace in other branches
  1. 6 vote_up_down.module \vote_up_down_tracker()
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 374
vote_up_down is a module that adds a widget for +1/-1 votes on nodes. It depends upon Voting API. It's based upon "simplevote.module".

Code

function vote_up_down_tracker() {
  if ($node = node_load(arg(1))) {
    $header = array(
      array(
        'data' => t('User'),
      ),
      array(
        'data' => t('Vote'),
      ),
      array(
        'data' => t('Date'),
      ),
    );
    $votes = votingapi_get_content_votes('node', $node->nid);
    foreach ($votes as $vote) {
      $account = user_load(array(
        'uid' => $vote[0]->uid,
        'status' => 1,
      ));
      $rows[] = array(
        theme('username', $account),
        $vote[0]->value,
        array(
          'data' => format_date($vote[0]->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();
  }
}