diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-01-24 14:48:36 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-01-24 14:48:36 +0000 |
commit | 03752e35a41992c3d61f2591980020c87af257e7 (patch) | |
tree | dd8d9f51a47716785083591d82ca873c201c1057 /modules/poll | |
parent | d407de4cec606623a5946805d2d42b580ccb116b (diff) | |
download | brdo-03752e35a41992c3d61f2591980020c87af257e7.tar.gz brdo-03752e35a41992c3d61f2591980020c87af257e7.tar.bz2 |
- Patch #34755 by chx et al: faster menu system. HEAD is temporary broken and there is no upgrade path yet.
Diffstat (limited to 'modules/poll')
-rw-r--r-- | modules/poll/poll.module | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 195d3b3b8..44b1613e6 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -224,59 +224,51 @@ function poll_insert($node) { } } +function _poll_menu_access($node, $perm, $inspect_allowvotes) { + return user_access($perm) && ($node->type == 'poll') && ($node->allowvotes || !$inspect_allowvotes); +} + /** * Implementation of hook_menu(). */ -function poll_menu($may_cache) { - $items = array(); - - if ($may_cache) { - $items[] = array('path' => 'poll', 'title' => t('Polls'), - 'callback' => 'poll_page', - 'access' => user_access('access content'), - 'type' => MENU_SUGGESTED_ITEM); - - $items[] = array('path' => 'poll/vote', - 'title' => t('Vote'), - 'callback' => 'poll_vote', - 'access' => user_access('vote on polls'), - 'type' => MENU_CALLBACK); - - $items[] = array('path' => 'poll/cancel', - 'title' => t('Cancel'), - 'callback' => 'poll_cancel', - 'access' => user_access('cancel own vote'), - 'type' => MENU_CALLBACK); - } - else { - // Add the CSS for this module - // We put this in !$may_cache so it's only added once per request - drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css'); - - if (arg(0) == 'node' && is_numeric(arg(1))) { - $node = node_load(arg(1)); - if ($node->type == 'poll') { - $items[] = array('path' => 'node/'. arg(1) .'/votes', - 'title' => t('Votes'), - 'callback' => 'poll_votes', - 'access' => user_access('inspect all votes'), - 'weight' => 3, - 'type' => MENU_LOCAL_TASK); - } - if ($node->type == 'poll' && $node->allowvotes) { - $items[] = array('path' => 'node/'. arg(1) .'/results', - 'title' => t('Results'), - 'callback' => 'poll_results', - 'access' => user_access('access content'), - 'weight' => 3, - 'type' => MENU_LOCAL_TASK); - } - } - } +function poll_menu() { + $items['poll'] = array( + 'title' => t('Polls'), + 'page callback' => 'poll_page', + 'access arguments' => array('access content'), + 'type' => MENU_SUGGESTED_ITEM, + ); + $items['poll/cancel/%'] = array( + 'title' => t('Cancel'), + 'page callback' => 'poll_cancel', + 'page arguments' => array(2), + 'access arguments' => array('cancel own vote'), + 'type' => MENU_CALLBACK, + ); + $items['node/%/votes'] = array( + 'title' => t('Votes'), + 'page callback' => 'poll_votes', + 'access callback' => '_poll_menu_access', + 'access arguments' => array(1, 'inspect all votes', FALSE), + 'weight' => 3, + 'type' => MENU_LOCAL_TASK, + ); + $items['node/%/results'] = array( + 'title' => t('Results'), + 'page callback' => 'poll_results', + 'access callback' => '_poll_menu_access', + 'access arguments' => array(1, 'access content', TRUE), + 'weight' => 3, + 'type' => MENU_LOCAL_TASK, + ); return $items; } +function poll_init() { + drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css'); +} + /** * Implementation of hook_load(). */ |