You are here

function advpoll_process_writein in Advanced Poll 7.2

Same name and namespace in other branches
  1. 7.3 advpoll.module \advpoll_process_writein()
  2. 7 advpoll.module \advpoll_process_writein()
2 calls to advpoll_process_writein()
advpoll_form_submit in ./advpoll.module
Submit handler for voting
advpoll_ranking_submit in advpoll_ranking/advpoll_ranking.module

File

./advpoll.module, line 806

Code

function advpoll_process_writein($nid, $writein, $data) {
  $node = node_load($nid);
  $id = dechex(time() * rand(5, 50));
  $writein_choice = array();
  if ($node) {
    $lang = $node->language;
    if (!isset($node->advpoll_choice[$lang])) {
      $lang = 'und';
    }
    $nodeChoices = $node->advpoll_choice[$lang];
    $writein_choice = array(
      'choice' => $writein,
      'write_in' => 1,
      'choice_id' => $id,
    );
    $nodeChoices[] = $writein_choice;
    $node->advpoll_choice[$lang] = $nodeChoices;
    node_save($node);
  }
  return $writein_choice;
}