summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-09-05 08:33:16 +0000
committerDries Buytaert <dries@buytaert.net>2007-09-05 08:33:16 +0000
commite0c1342316395727f19617c02884077c92ece155 (patch)
tree8e82d182dc2cb6a480c5fc80bc1b80d62f2e06dc /modules
parent53818e811e7c699a00e53f9dfe539e000677d734 (diff)
downloadbrdo-e0c1342316395727f19617c02884077c92ece155.tar.gz
brdo-e0c1342316395727f19617c02884077c92ece155.tar.bz2
- Patch #172836 by Crell: split poll module.
Diffstat (limited to 'modules')
-rw-r--r--modules/poll/poll.module53
-rw-r--r--modules/poll/poll.pages.inc57
2 files changed, 60 insertions, 50 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 8c6f60319..c3ddc485c 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -72,6 +72,7 @@ function poll_menu() {
'page callback' => 'poll_page',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'poll.pages.inc',
);
$items['node/%node/votes'] = array(
@@ -82,6 +83,7 @@ function poll_menu() {
'access arguments' => array(1, 'inspect all votes', FALSE),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
+ 'file' => 'poll.pages.inc',
);
$items['node/%node/results'] = array(
@@ -92,6 +94,7 @@ function poll_menu() {
'access arguments' => array(1, 'access content', TRUE),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
+ 'file' => 'poll.pages.inc',
);
return $items;
}
@@ -410,25 +413,6 @@ 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.
- $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, 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>';
- }
- $output .= '</ul>';
- $output .= theme("pager", NULL, 15);
- return $output;
-}
-
-/**
* Creates a simple teaser that lists all the choices.
*
* This is primarily used for RSS.
@@ -625,37 +609,6 @@ function poll_cancel($form, &$form_state) {
}
/**
- * Callback for the 'results' tab for polls you can vote on
- */
-function poll_results($node) {
- drupal_set_title(check_plain($node->title));
- $node->show_results = TRUE;
- return node_show($node, 0);
-}
-
-/**
- * Callback for the 'votes' tab for polls you can see other votes on
- */
-function poll_votes($node) {
- drupal_set_title(check_plain($node->title));
- $output = t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.');
-
- $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
- $header[] = array('data' => t('Vote'), 'field' => 'pv.chorder');
-
- $result = pager_query("SELECT pv.chorder, pv.uid, pv.hostname, u.name FROM {poll_votes} pv LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d" . tablesort_sql($header), 20, 0, NULL, $node->nid);
- $rows = array();
- while ($vote = db_fetch_object($result)) {
- $rows[] = array(
- $vote->name ? theme('username', $vote) : check_plain($vote->hostname),
- check_plain($node->choice[$vote->chorder]['chtext']));
- }
- $output .= theme('table', $header, $rows);
- $output .= theme('pager', NULL, 20, 0);
- return $output;
-}
-
-/**
* Implementation of hook_user().
*/
function poll_user($op, &$edit, &$user) {
diff --git a/modules/poll/poll.pages.inc b/modules/poll/poll.pages.inc
new file mode 100644
index 000000000..387e08b2e
--- /dev/null
+++ b/modules/poll/poll.pages.inc
@@ -0,0 +1,57 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * User page callbacks for the poll module.
+ */
+
+/**
+ * Menu callback to provide a simple list of all polls available.
+ */
+function poll_page() {
+ // 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, 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>';
+ }
+ $output .= '</ul>';
+ $output .= theme("pager", NULL, 15);
+ return $output;
+}
+
+/**
+ * Callback for the 'votes' tab for polls you can see other votes on
+ */
+function poll_votes($node) {
+ drupal_set_title(check_plain($node->title));
+ $output = t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.');
+
+ $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
+ $header[] = array('data' => t('Vote'), 'field' => 'pv.chorder');
+
+ $result = pager_query("SELECT pv.chorder, pv.uid, pv.hostname, u.name FROM {poll_votes} pv LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d" . tablesort_sql($header), 20, 0, NULL, $node->nid);
+ $rows = array();
+ while ($vote = db_fetch_object($result)) {
+ $rows[] = array(
+ $vote->name ? theme('username', $vote) : check_plain($vote->hostname),
+ check_plain($node->choice[$vote->chorder]['chtext']));
+ }
+ $output .= theme('table', $header, $rows);
+ $output .= theme('pager', NULL, 20, 0);
+ return $output;
+}
+
+/**
+ * Callback for the 'results' tab for polls you can vote on
+ */
+function poll_results($node) {
+ drupal_set_title(check_plain($node->title));
+ $node->show_results = TRUE;
+ return node_show($node, 0);
+}