function poll_view_voting in Drupal 4
Same name and namespace in other branches
- 5 modules/poll/poll.module \poll_view_voting()
- 6 modules/poll/poll.module \poll_view_voting()
- 7 modules/poll/poll.module \poll_view_voting()
Generates the voting form for a poll.
1 call to poll_view_voting()
- poll_view in modules/
poll.module - Implementation of hook_view().
File
- modules/
poll.module, line 296 - Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_view_voting(&$node, $teaser, $page, $block) {
// Check for a valid form token to protect against cross site request forgeries.
if ($_POST['op'] == t('Vote') && drupal_valid_token($_POST['edit']['form_token'], 'poll_view_voting', TRUE)) {
poll_vote($node);
}
if ($node->choice) {
$list = array();
foreach ($node->choice as $i => $choice) {
$list[$i] = check_plain($choice['chtext']);
}
$form['choice'] = array(
'#type' => 'radios',
'#title' => $block ? check_plain($node->title) : '',
'#default_value' => -1,
'#options' => $list,
);
}
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid,
);
$form['vote'] = array(
'#type' => 'submit',
'#value' => t('Vote'),
);
$form['#action'] = url('node/' . $node->nid);
return drupal_get_form('poll_view_voting', $form);
}