You are here

function vud_node_tracker in Vote Up/Down 7

Same name and namespace in other branches
  1. 6.3 vud_node/vud_node.module \vud_node_tracker()
  2. 6.2 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 243
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(
      'entity_type' => 'node',
      'entity_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', array(
          'account' => $account,
        )),
        $vote['value'],
        array(
          'data' => format_date($vote['timestamp'], 'small'),
          'class' => 'nowrap',
        ),
      );
    }
    drupal_set_title(check_plain($node->title));
    $output = theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
    $output .= theme('pager', array());
    return $output;
  }
  else {
    drupal_not_found();
  }
}