You are here

function vud_user_votes in Vote Up/Down 6.2

Same name and namespace in other branches
  1. 6.3 vud.module \vud_user_votes()

Menu callback; display all votes for a user.

1 string reference to 'vud_user_votes'
vud_menu in ./vud.module
Implementation of hook_menu().

File

./vud.module, line 138

Code

function vud_user_votes($account) {
  $header = array(
    array(
      'data' => t('Node'),
    ),
    array(
      'data' => t('Vote'),
    ),
    array(
      'data' => t('Date'),
    ),
  );
  $sql = db_rewrite_sql("SELECT n.nid, n.title, v.value, v.timestamp FROM {node} n LEFT JOIN {votingapi_vote} v\n    ON n.nid = v.content_id\n    WHERE v.uid = %d AND v.tag = '%s' AND v.content_type = 'node' AND n.status = 1\n    ORDER BY v.timestamp DESC");
  $result = pager_query($sql, 25, 0, NULL, $account->uid, variable_get('vud_tag', 'vote'));
  $rows = array();
  while ($node = db_fetch_object($result)) {
    $rows[] = array(
      l($node->title, 'node/' . $node->nid),
      $node->value,
      t('!time ago', array(
        '!time' => format_interval(time() - $node->timestamp),
      )),
    );
  }
  drupal_set_title(check_plain($account->name));
  $output = theme('table', $header, $rows);
  $output .= theme('pager', NULL, 25);
  return $output;
}