function advpoll_promote_writein_form_submit in Advanced Poll 7.2
Same name and namespace in other branches
- 7.3 includes/advpoll.pages.inc \advpoll_promote_writein_form_submit()
- 7 includes/advpoll.pages.inc \advpoll_promote_writein_form_submit()
File
- includes/
advpoll.pages.inc, line 428
Code
function advpoll_promote_writein_form_submit($form, &$form_state) {
$selected = array();
$nid = $form_state['build_info']['args'][0]->nid;
$options = $form['promote_writein']['choices']['#options'];
foreach ($options as $option) {
if ($form['promote_writein']['choices'][$option]['#checked']) {
$selected[] = strtolower(strip_tags($option));
}
}
if ($selected) {
$node = node_load($nid);
if ($node) {
$lang = $node->language;
if (!isset($node->advpoll_choice[$lang])) {
$lang = 'und';
}
$node_choices = $node->advpoll_choice[$lang];
$updated_choices = array();
foreach ($node_choices as $item) {
$choice = strtolower(strip_tags($item['choice']));
if (in_array($choice, $selected)) {
$updated_choices[] = array(
'choice' => $item['choice'],
'write_in' => 0,
'choice_id' => $item['choice_id'],
);
}
else {
$updated_choices[] = array(
'choice' => $item['choice'],
'write_in' => $item['write_in'],
'choice_id' => $item['choice_id'],
);
}
}
$node->advpoll_choice[$lang] = $updated_choices;
node_save($node);
}
}
}