function poll_page

7.x poll.pages.inc poll_page()

Menu callback to provide a simple list of all polls available.

2 string references to 'poll_page'
drupal-6.filled.database.php in drupal/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
Filled installation of Drupal 6.17, for test purposes.
poll_menu in drupal/modules/poll/poll.module
Implements hook_menu().

File

drupal/modules/poll/poll.pages.inc, line 11
User page callbacks for the poll module.

Code

function poll_page() {
  $polls_per_page = 15;

  $count_select = db_select('node', 'n');
  $count_select->addExpression('COUNT(*)', 'expression');
  $count_select->join('poll', 'p', 'p.nid = n.nid');
  $count_select->condition('n.status', 1);

  // List all polls.
  $select = db_select('node', 'n');
  $select->join('poll', 'p', 'p.nid = n.nid');
  $select->join('poll_choice', 'c', 'c.nid = n.nid');
  $select->addExpression('SUM(c.chvotes)', 'votes');
  $select = $select->fields('n', array('nid', 'title', 'created'))->fields('p', array('active'))->condition('n.status', 1)->orderBy('n.created', 'DESC')->groupBy('n.nid')->groupBy('n.title')->groupBy('p.active')->groupBy('n.created')->extend('PagerDefault')->limit($polls_per_page)->addTag('node_access');
  $select->setCountQuery($count_select);
  $queried_nodes = $select->execute()->fetchAllAssoc('nid');

  $output = '<ul>';
  foreach ($queried_nodes as $node) {
    $output .= '<li>' . l($node->title, "node/$node->nid") . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
  }
  $output .= '</ul>';
  $output .= theme('pager');
  return $output;
}