You are here

function eloqua_webform_submit in Eloqua 6

Same name and namespace in other branches
  1. 7.2 eloqua_webform/eloqua_webform.module \eloqua_webform_submit()
  2. 7 eloqua_webform/eloqua_webform.module \eloqua_webform_submit()

Submit handler for the webform

Parameters

$form array:

$form_state array:

1 string reference to 'eloqua_webform_submit'
eloqua_form_alter in ./eloqua.module
Implementation of hook_form_alter().

File

./eloqua.module, line 384

Code

function eloqua_webform_submit($form, $form_state) {

  // Only process upon the final page submission, unless otherwise told
  $process_every_page = $form_state['values']['process_every_page'];
  if (!$process_every_page) {
    if (!array_key_exists('webform_completed', $form_state) || !$form_state['webform_completed']) {
      return;
    }
  }
  $values = array();
  $values['form_post'] = $form_state['values'];
  $values['user_headers'] = unserialize($form_state['values']['user_headers']);

  // Check for serialization errors
  if ($values['user_headers'] == FALSE) {
    $values['user_headers'] = array();
  }
  unset($values['form_post']['user_headers']);

  // Save the values and essential information to the database
  $info = new stdClass();
  $info->{ELOQUA_POST_FIELD_FORM_ID} = $form_state['values']['form_id'];
  $info->{ELOQUA_POST_FIELD_POST_TIME} = time();
  $info->{ELOQUA_POST_FIELD_STATUS} = ELOQUA_STATUS_NEW;
  $info->{ELOQUA_POST_FIELD_DATA} = $values;
  $post_id = eloqua_post_create($info);
  if (!$post_id) {
    $message = t('Unable to save submitted entry. <pre>!data</pre>');
    $vars = array(
      '!data' => var_export($info, TRUE),
    );
    watchdog(ELOQUA_WATCHDOG_CATEGORY, $message, $vars, WATCHDOG_NOTICE);
  }
}