Same name and namespace in other branches
  1. 4.7.x modules/poll.module \poll_menu()
  2. 5.x modules/poll/poll.module \poll_menu()
  3. 6.x modules/poll/poll.module \poll_menu()
  4. 7.x modules/poll/poll.module \poll_menu()

Implementation of hook_menu().

File

modules/poll.module, line 186
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function poll_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $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,
    );
    $items[] = array(
      'path' => 'poll/vote',
      'title' => t('vote'),
      'callback' => 'poll_vote',
      'access' => user_access('vote on polls'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(array(
        'nid' => arg(1),
      ));
      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;
}