You are here

function poll_menu in Drupal 5

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

Implementation of hook_menu().

File

modules/poll/poll.module, line 230
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' => '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;
}