diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2002-06-01 20:19:18 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2002-06-01 20:19:18 +0000 |
commit | e0c1980329ac9f0b8906d95934f615e3bd5f47df (patch) | |
tree | dfe7fadd26aacf32ca4feda987ef5e65965402db | |
parent | f520a8b413fb9edd030802fdc6045f00529fa30a (diff) | |
download | brdo-e0c1980329ac9f0b8906d95934f615e3bd5f47df.tar.gz brdo-e0c1980329ac9f0b8906d95934f615e3bd5f47df.tar.bz2 |
Poll.module:
Added a page showing a list of older polls.
-rw-r--r-- | modules/poll.module | 23 | ||||
-rw-r--r-- | modules/poll/poll.module | 23 |
2 files changed, 42 insertions, 4 deletions
diff --git a/modules/poll.module b/modules/poll.module index 6f8f5c403..9e4d97de7 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -122,6 +122,9 @@ function poll_link($type) { if ($type == "menu.create" && user_access("post content")) { $links[] = lm(t("create poll"), array("mod" => "node", "op" => "add", "type" => "poll"), "", array("title" => t("Add a new poll."))); } + else if ($type == "page" && user_access("access content")) { + $links[] = lm(t("polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + } return $links ? $links : array(); } @@ -145,6 +148,18 @@ function poll_node($field) { return $info[$field]; } +function poll_page() { + global $theme; + + $theme->header(); + $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type='poll' AND status='1' AND moderate='0' GROUP BY n.nid"); + while ($node = db_fetch_object($result)) { + $output .= "<li>". l($node->title, array("id" => $node->nid)) ." - ". format_plural($node->votes, "vote", "votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>"; + } + $theme->box(t("Polls"), $output); + $theme->footer(); +} + function poll_perm() { return array("vote on polls"); } @@ -233,7 +248,9 @@ function poll_view(&$node, $main = 0, $block = 0) { else { $output .= "</td><td valign=\"middle\"><div align=\"right\"> ". form_submit(t("Vote")) ."</div></td></tr></table>"; } - $output .= $block ? "<div align=\"center\">". $theme->links(link_node($node, $main)) ."</div>" : ""; + $links = link_node($node, $main); + $links[] = lm(t("older polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + $output .= $block ? "<div align=\"center\">". $theme->links($links) ."</div>" : ""; $output .= "</form>"; } else { @@ -273,7 +290,9 @@ function poll_view(&$node, $main = 0, $block = 0) { // Prevent a 'read more' link in the side-block. $node->body = $node->teaser = ""; } - $output .= "<br /><div align=\"center\">Total votes: ". $votestotal . ($block ? "<br />". $theme->links(link_node($node, $main)) : "") ."</div>"; + $links = link_node($node, $main); + $links[] = lm(t("older polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + $output .= "<br /><div align=\"center\">Total votes: ". $votestotal . ($block ? "<br />". $theme->links($links) : "") ."</div>"; } // Force the output on both the mainpage and elsewhere $node->body = $output; diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 6f8f5c403..9e4d97de7 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -122,6 +122,9 @@ function poll_link($type) { if ($type == "menu.create" && user_access("post content")) { $links[] = lm(t("create poll"), array("mod" => "node", "op" => "add", "type" => "poll"), "", array("title" => t("Add a new poll."))); } + else if ($type == "page" && user_access("access content")) { + $links[] = lm(t("polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + } return $links ? $links : array(); } @@ -145,6 +148,18 @@ function poll_node($field) { return $info[$field]; } +function poll_page() { + global $theme; + + $theme->header(); + $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type='poll' AND status='1' AND moderate='0' GROUP BY n.nid"); + while ($node = db_fetch_object($result)) { + $output .= "<li>". l($node->title, array("id" => $node->nid)) ." - ". format_plural($node->votes, "vote", "votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>"; + } + $theme->box(t("Polls"), $output); + $theme->footer(); +} + function poll_perm() { return array("vote on polls"); } @@ -233,7 +248,9 @@ function poll_view(&$node, $main = 0, $block = 0) { else { $output .= "</td><td valign=\"middle\"><div align=\"right\"> ". form_submit(t("Vote")) ."</div></td></tr></table>"; } - $output .= $block ? "<div align=\"center\">". $theme->links(link_node($node, $main)) ."</div>" : ""; + $links = link_node($node, $main); + $links[] = lm(t("older polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + $output .= $block ? "<div align=\"center\">". $theme->links($links) ."</div>" : ""; $output .= "</form>"; } else { @@ -273,7 +290,9 @@ function poll_view(&$node, $main = 0, $block = 0) { // Prevent a 'read more' link in the side-block. $node->body = $node->teaser = ""; } - $output .= "<br /><div align=\"center\">Total votes: ". $votestotal . ($block ? "<br />". $theme->links(link_node($node, $main)) : "") ."</div>"; + $links = link_node($node, $main); + $links[] = lm(t("older polls"), array("mod" => "poll"), "", array("title" => t("View the list of polls on this site."))); + $output .= "<br /><div align=\"center\">Total votes: ". $votestotal . ($block ? "<br />". $theme->links($links) : "") ."</div>"; } // Force the output on both the mainpage and elsewhere $node->body = $output; |