function advpoll_menu in Advanced Poll 5
Same name and namespace in other branches
- 6.3 advpoll.module \advpoll_menu()
- 6 advpoll.module \advpoll_menu()
- 6.2 advpoll.module \advpoll_menu()
- 7.3 advpoll.module \advpoll_menu()
- 7 advpoll.module \advpoll_menu()
- 7.2 advpoll.module \advpoll_menu()
Implementation of hook_menu().
File
- ./
advpoll.module, line 75 - Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.
Code
function advpoll_menu($may_cache) {
global $user;
$modes = _advpoll_list_modes();
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'advpoll/cancel',
'title' => t('Cancel'),
'callback' => 'advpoll_cancel',
'access' => user_access('cancel own vote'),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'polls',
'title' => t('Advanced Polls'),
'callback' => 'advpoll_page',
'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM,
);
}
else {
// Use Poll modules stylesheet, no need to duplicate at this point.
// We put this in !$may_cache so it's only added once per request.
drupal_add_css(drupal_get_path('module', 'poll') . '/poll.css');
// Need to be able to extract the nid.
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load($nid);
// Make sure we're on the actual poll node's page.
if (strstr($node->type, 'advpoll_') == 0) {
// Show the results tab.
if (_advpoll_is_active($node) && !$node->voted && _advpoll_can_view_results($node)) {
$items[] = array(
'path' => 'node/' . $nid . '/results',
'title' => t('Results'),
'callback' => 'advpoll_results',
'access' => user_access('access content'),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
}
// Show the votes tab.
if ($node->show_votes) {
$items[] = array(
'path' => 'node/' . $nid . '/votes',
'title' => t('Votes'),
'callback' => 'advpoll_votes_page',
'access' => user_access('inspect all votes'),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
}
// Show electoral list tab if using the functionality.
if ($node->use_list) {
$items[] = array(
'path' => 'node/' . $nid . '/electoral_list',
'title' => t('Electoral list'),
'callback' => 'advpoll_electoral_list_page',
'access' => user_access('access electoral list'),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
// Allow voters to be removed.
$items[] = array(
'path' => 'node/' . $nid . '/remove',
'callback' => 'advpoll_remove_voter',
'access' => user_access('administer polls'),
'weight' => 3,
'type' => MENU_CALLBACK,
);
}
// Allow votes to be reset.
$items[] = array(
'path' => 'node/' . $nid . '/reset',
'callback' => 'drupal_get_form',
'callback arguments' => 'advpoll_reset_confirm',
'access' => user_access('administer polls'),
'weight' => 3,
'type' => MENU_CALLBACK,
);
// Show the write-ins tab if there is at least one.
if ($node->writeins) {
$has_writeins = FALSE;
foreach ($node->choice as $choice) {
if ($choice['writein']) {
$has_writeins = TRUE;
break;
}
}
if ($has_writeins) {
$items[] = array(
'path' => 'node/' . $nid . '/writeins',
'title' => t('Write-ins'),
'callback' => 'advpoll_writeins_page',
'access' => user_access('administer polls'),
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
}
}
}
}
}
return $items;
}