You are here

function webform_insert in Webform 5

Same name and namespace in other branches
  1. 5.2 webform.module \webform_insert()
  2. 6.2 webform.module \webform_insert()

Implemenation of hook_insert().

1 call to webform_insert()
webform_update in ./webform.module
Implemenation of hook_update().

File

./webform.module, line 218

Code

function webform_insert($node) {
  global $user;

  // Correctly set the submission limits.
  if ($_POST['enforce_limit'] === 'no') {
    $node->submit_limit = '-1';
    $node->submit_interval = '157784630';

    // 5 years, close enough to 'ever'.
  }

  // Insert the Webform.
  db_query("INSERT INTO {webform} (nid, confirmation, redirect_post, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit) VALUES (%d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", $node->nid, $node->confirmation, $node->redirect_post, $node->submit_limit, $node->submit_interval, $node->email, $node->email_from_name, $node->email_from_address, $node->email_subject, $node->additional_validate, $node->additional_submit);

  // Insert the components into the database.
  if (is_array($node->webformcomponents) && !empty($node->webformcomponents)) {
    foreach ($node->webformcomponents as $cid => $component) {
      db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d)", $node->nid, $cid, $component['parent'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'] ? 1 : 0, $component['weight']);
    }
  }
}