You are here

function advpoll_insert in Advanced Poll 5

Same name and namespace in other branches
  1. 6.3 advpoll.module \advpoll_insert()
  2. 6 advpoll.module \advpoll_insert()
  3. 6.2 advpoll.module \advpoll_insert()

Implementation of hook_insert().

This is called upon node creation.

File

./advpoll.module, line 714
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_insert($node) {
  $mode = _advpoll_get_mode($node->type);
  db_query("INSERT INTO {advpoll} (nid, mode, use_list, active, max_choices, algorithm, show_votes, start_date, end_date, writeins, show_writeins, question) VALUES (%d, '%s', %d, %d, %d, '%s', %d, '%s', '%s', %d, %d, '%s')", $node->nid, $mode, $node->settings['use_list'], !$node->settings['close'], $node->settings['max_choices'], $node->settings['algorithm'], $node->settings['show_votes'], $node->settings['start_date'] ? strtotime($node->settings['start_date']) : 0, $node->settings['end_date'] ? strtotime($node->settings['end_date']) : 0, $node->settings['writeins'], $node->settings['show_writeins'], $node->question);
  $raw_choices = explode("\n", $_POST['choice_area']);
  $choices = array();
  foreach ($raw_choices as $choice_line) {
    $choices[] = array(
      'label' => $choice_line,
    );
  }

  // Insert the choices.
  _advpoll_insert_choices($node->nid, $choices);
}