poll_menu

Versions
4.6 – 5
poll_menu($may_cache)
6 – 7
poll_menu()

Implementation of hook_menu().

Code

modules/poll/poll.module, line 230

<?php
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);
      }
    }
  }

  return $items;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.