You are here

function _photos_down_vote in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.down.inc \_photos_down_vote()
1 call to _photos_down_vote()
photos_down_page in inc/photos.down.inc

File

inc/photos.down.inc, line 124

Code

function _photos_down_vote($fid) {
  $header = array(
    array(
      'data' => t('Vote user'),
      'field' => 'v.uid',
    ),
    array(
      'data' => t('Vote result'),
      'field' => 'v.value',
    ),
    array(
      'data' => t('Vote time'),
      'field' => 'v.timestamp',
      'sort' => 'desc',
    ),
  );
  $rows = array();
  $result = pager_query("SELECT v.uid, u.name, v.value, v.timestamp, v.vote_source FROM {votingapi_vote} v LEFT JOIN {users} u ON u.uid = v.uid WHERE content_type = '%s' AND content_id = %d" . tablesort_sql($header), 30, 0, NULL, 'image', $fid);
  while ($a = db_fetch_object($result)) {
    if ($a->uid != 0) {
      $name = theme('username', $a);
    }
    else {
      $name = $a->vote_source;
    }
    $rows[] = array(
      $name,
      $a->value,
      format_date($a->timestamp, 'small'),
    );
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No vote available.'),
        'colspan' => 3,
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 30, 0);
  drupal_set_title(t('See a image vote'));
  return $output;
}