function advpoll_view in Advanced Poll 6.2
Same name and namespace in other branches
- 5 advpoll.module \advpoll_view()
- 6.3 advpoll.module \advpoll_view()
- 6 advpoll.module \advpoll_view()
Implementation of hook_view().
1 call to advpoll_view()
File
- ./
advpoll.module, line 791 - Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.
Code
function advpoll_view($node, $teaser = FALSE, $page = FALSE) {
drupal_add_css(drupal_get_path('module', 'advpoll') . '/advpoll.css', 'module');
$status = _advpoll_is_active($node, TRUE);
// Add question to content if defined.
if ($node->question !== '') {
$node->content['question'] = array(
'#weight' => 1,
'#value' => theme('advpoll_question', check_plain($node->question)),
);
}
if ($node->build_mode == NODE_BUILD_PREVIEW) {
// Previewing a node, so display voting form instead of results.
$poll = drupal_get_form('advpoll_voting_' . _advpoll_get_mode($node->type) . '_form', $node, $teaser, $page, $status);
}
else {
if (!$node->voted && arg(2) != 'results' && ($status == 'open' || $status == 'pending')) {
// OLD: else if ((!$node->voted && arg(2) != 'results' && ($status == 'open' || $status == 'pending')) || $_POST['op'] == 'Vote') {
// User hasn't voted, we're not on the results tab and poll is open or
// opening in the future. Also, we check the $_POST array if the user tried
// to submit a vote, so we can validate and give an error if the user has
// already voted on the poll.
$poll = drupal_get_form('advpoll_voting_' . $node->mode . '_form', $node, $teaser, $page, $status);
static $add_js = TRUE;
if ($add_js) {
// Add javascript for posting voting forms with Ajax.
drupal_add_js(drupal_get_path('module', 'advpoll') . '/advpoll-vote.js', 'module');
drupal_add_js('misc/jquery.form.js', 'module');
$add_js = FALSE;
}
}
else {
// Show results (the user has voted, poll is closed or poll has passed).
if (user_access('show vote results')) {
$poll = advpoll_view_results($node, $teaser, $page);
}
elseif (user_access('cancel own vote')) {
$poll = _advpoll_show_cancel_form($node);
}
}
}
$node->content['poll'] = array(
'#weight' => 2,
'#value' => $poll,
);
return node_prepare($node, $teaser);
}