From e0c1980329ac9f0b8906d95934f615e3bd5f47df Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Sat, 1 Jun 2002 20:19:18 +0000 Subject: Poll.module: Added a page showing a list of older polls. --- modules/poll.module | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'modules/poll.module') 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 .= "
  • ". l($node->title, array("id" => $node->nid)) ." - ". format_plural($node->votes, "vote", "votes") ." - ". ($node->active ? t("open") : t("closed")) ."
  • "; + } + $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 .= "
       ". form_submit(t("Vote")) ."
    "; } - $output .= $block ? "
    ". $theme->links(link_node($node, $main)) ."
    " : ""; + $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 ? "
    ". $theme->links($links) ."
    " : ""; $output .= ""; } 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 .= "
    Total votes: ". $votestotal . ($block ? "
    ". $theme->links(link_node($node, $main)) : "") ."
    "; + $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 .= "
    Total votes: ". $votestotal . ($block ? "
    ". $theme->links($links) : "") ."
    "; } // Force the output on both the mainpage and elsewhere $node->body = $output; -- cgit v1.2.3