summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module30
1 files changed, 20 insertions, 10 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index c63fd6f6a..757f183a1 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -16,7 +16,7 @@ function poll_help($section) {
<li>To administer polls you need the \"administer nodes\" permission.</li>
</ul>
<p>Creating a poll is much like creating any other node. Click \"create poll\" in your user box. The title of the poll should be the question, then enter the answers and the \"base\" vote counts. You can also choose the time period over which the vote will run.</p><p>The <a href=\"%poll\">Poll</a> item in the navigation links will take you to a page where you can see all the current polls, vote on them (if you haven't already) and view the results.</p>", array("%permissions" => url("admin/user/permission"), "%poll" => url("poll")));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t("Enables your site to capture votes on different topics in the form of multiple choice questions.");
case 'node/add#poll':
return t("A poll is a multiple-choice question which visitors can vote on.");
@@ -185,11 +185,7 @@ function poll_insert($node) {
function poll_link($type, $node = 0, $main) {
$links = array();
- if ($type == 'system') {
- menu('node/add/poll', t('poll'), user_access('create polls') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- menu('poll', t('polls'), user_access('access content') ? 'poll_page' : MENU_DENIED, 0, MENU_HIDE);
- }
- else if ($type == 'page' && user_access('access content')) {
+ if ($type == 'page' && user_access('access content')) {
$links[] = l(t('polls'), 'poll', array('title' => t('View the list of polls on this site.')));
}
else if ($type == 'node' && $node->type == 'poll') {
@@ -200,10 +196,10 @@ function poll_link($type, $node = 0, $main) {
if ($node->allowvotes) {
if (arg(3) == 'results') {
- $links[] = l(t('voting form'), 'node/view/'. $node->nid);
+ $links[] = l(t('voting form'), 'node/'. $node->nid);
}
else {
- $links[] = l(t('view results'), 'node/view/'. $node->nid .'/results');
+ $links[] = l(t('view results'), 'node/'. $node->nid .'/results');
}
}
}
@@ -212,6 +208,20 @@ function poll_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function poll_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/poll', 'title' => t('poll'),
+ 'access' => user_access('create polls'));
+ $items[] = array('path' => 'poll', 'title' => t('polls'),
+ 'callback' => 'poll_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
+}
+
+/**
* Determine an adjusted user id, to allow for basic tracking of anonymous
* users (IP-based).
*/
@@ -261,7 +271,7 @@ function poll_page() {
$result = pager_query("SELECT n.nid, n.title, p.active, 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 type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC", 15);
$output = '<ul>';
while ($node = db_fetch_object($result)) {
- $output .= '<li>'. l($node->title, "node/view/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
+ $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);
@@ -307,7 +317,7 @@ function poll_view_voting(&$node, $main, $page, $block) {
$form .= form_hidden('nid', $node->nid);
$form .= form_submit(t('Vote'), 'vote') .'</div>';
- $output .= form($form, 'post', url('node/view/'. $node->nid));
+ $output .= form($form, 'post', url('node/'. $node->nid));
$output .= '</div>';
return $output;