function advpoll_view in Advanced Poll 6.3
Same name and namespace in other branches
- 5 advpoll.module \advpoll_view()
- 6 advpoll.module \advpoll_view()
- 6.2 advpoll.module \advpoll_view()
Implementation of hook_view().
2 calls to advpoll_view()
- advpoll_latest_poll in ./
advpoll.module - .
- theme_advpoll_view_block_poll in ./
advpoll.module - Content of the block when a poll is flagged to display as a block
File
- ./
advpoll.module, line 880 - 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);
$displayResults = _advpoll_check_settings($node);
//print 'display results '.$displayResults;
if ($node->build_mode == NODE_BUILD_PREVIEW || !$displayResults) {
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;
}
// Previewing a node, so display voting form instead of results.
$mode = _advpoll_get_mode($node->type);
if ($mode) {
$poll = drupal_get_form('advpoll_voting_' . $mode . '_form', $node, $teaser, $page, $status);
}
}
else {
if (!$node->voted && arg(2) != 'results' && ($status == 'open' || $status == 'pending') && $displayResults) {
// 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);
}