function advpoll_node_view in Advanced Poll 7.3
Same name and namespace in other branches
- 7 advpoll.module \advpoll_node_view()
- 7.2 advpoll.module \advpoll_node_view()
Implements hook_node_view().
File
- ./
advpoll.module, line 172
Code
function advpoll_node_view($node, $view_mode) {
if ($node->type == 'advpoll') {
$data = advpoll_get_data($node);
if ($data->behavior == 'approval' || $data->behavior == 'pool') {
drupal_add_css(drupal_get_path('module', 'advpoll') . '/css/advpoll.css', array(
'group' => CSS_DEFAULT,
'every_page' => TRUE,
));
// Use existing weight if defined.
$weight = 1;
if (!empty($node->content['advpoll_choice']['#weight'])) {
$weight = $node->content['advpoll_choice']['#weight'];
}
// Replace the markup for choices with appropriate markup.
unset($node->content['advpoll_choice']);
// Check for eligibility to vote.
if (advpoll_user_eligibility($node)) {
// Print out voting form.
$voteform = drupal_get_form('advpoll_choice_form', $node);
$node->content['advpoll_choice'] = array(
0 => $voteform,
'#weight' => $weight,
);
}
else {
$results = advpoll_display_results($node->nid, $data);
$node->content['advpoll_choice'] = array(
'#markup' => $results,
'#weight' => $weight,
);
}
}
}
}