You are here

function advpoll_page in Advanced Poll 5

Same name and namespace in other branches
  1. 6.3 advpoll.pages.inc \advpoll_page()
  2. 6 advpoll.pages.inc \advpoll_page()
  3. 6.2 advpoll.pages.inc \advpoll_page()
1 string reference to 'advpoll_page'
advpoll_menu in ./advpoll.module
Implementation of hook_menu().

File

./advpoll.module, line 800
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

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;
}