Commit 323fa356 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#110511 by bjaspan: poll listing page should have a 'count_sql' because the...

#110511 by bjaspan: poll listing page should have a 'count_sql' because the original query uses group by, so it is not countable properly
parent 22a37e6f
......@@ -413,10 +413,12 @@ function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
* Menu callback to provide a simple list of all polls available.
*/
function poll_page() {
// List all polls
// List all polls.
$sql = "SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC";
// Count all polls for the pager.
$count_sql = 'SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1';
$sql = db_rewrite_sql($sql);
$result = pager_query($sql, 15);
$result = pager_query($sql, 15, 0, $count_sql);
$output = '<ul>';
while ($node = db_fetch_object($result)) {
$output .= '<li>'. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '@count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment