You are here

function advpoll_page in Advanced Poll 6.2

Same name and namespace in other branches
  1. 5 advpoll.module \advpoll_page()
  2. 6.3 advpoll.pages.inc \advpoll_page()
  3. 6 advpoll.pages.inc \advpoll_page()

List all polls as a page.

1 string reference to 'advpoll_page'
advpoll_menu in ./advpoll.module
Implementation of hook_menu().

File

./advpoll.pages.inc, line 11
Page callbacks for the advpoll module.

Code

function advpoll_page() {

  // List all polls
  $sql = "SELECT n.nid, n.title, p.active, n.created, c.value AS votes FROM {node} n INNER JOIN {advpoll} p ON n.nid = p.nid INNER JOIN {votingapi_cache} c ON n.nid = c.content_id WHERE n.status = 1 AND c.tag = '_advpoll' AND c.function = 'total_votes' AND c.content_type = 'advpoll' GROUP BY n.nid, n.title, p.active, n.created, c.value ORDER BY n.created DESC";
  $sql = db_rewrite_sql($sql);
  $result = pager_query($sql, 15);
  $output = '<ul>';
  while ($node = db_fetch_object($result)) {
    $output .= '<li>' . l($node->title, 'node/' . $node->nid) . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . (_advpoll_is_active($node) ? t('open') : t('closed')) . '</li>';
  }
  $output .= '</ul>';
  $output .= theme('pager', NULL, 15);
  return $output;
}