You are here

function vote_up_down_user_votes in Vote Up/Down 5

Same name and namespace in other branches
  1. 6 vote_up_down.module \vote_up_down_user_votes()
1 string reference to 'vote_up_down_user_votes'
vote_up_down_menu in ./vote_up_down.module
Implementation of hook_menu().

File

./vote_up_down.module, line 404
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_user_votes() {
  if ($account = user_load(array(
    'uid' => arg(1),
    'status' => 1,
  ))) {
    if ($account->status || user_access('administer users')) {
      $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 ON n.nid = v.content_id WHERE v.uid = %d AND v.tag = '%s' AND v.content_type = 'node' AND n.status = 1 ORDER BY v.timestamp DESC");
      $result = pager_query($sql, 25, 0, NULL, $account->uid, variable_get('vote_up_down_tag', 'vote'));
      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;
    }
    else {
      drupal_access_denied();
    }
  }
  else {
    drupal_not_found();
  }
}