You are here

function eloqua_webform_submit in Eloqua 7

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

Form submission handler for eloqua_admin_form().

See also

eloqua_webform_form_alter()

1 string reference to 'eloqua_webform_submit'
eloqua_webform_form_alter in eloqua_webform/eloqua_webform.module
Implements hook_form_alter().

File

eloqua_webform/eloqua_webform.module, line 368

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->{'form_id'} = $form_state['values']['form_id'];
  $info->{'post_time'} = time();
  $info->{'status'} = ELOQUA_STATUS_NEW;
  $info->{'data'} = $values;
  $post = eloqua_post_create($info);

  // Do we want to process immediately?
  if (variable_get('eloqua_webform_process_submit', 0)) {
    _eloqua_cron($post);
  }
  if (!isset($post->post_id)) {
    $message = t('Unable to save submitted entry. <pre>!data</pre>');
    $vars = array(
      '!data' => var_export($info, TRUE),
    );
    watchdog('eloqua', $message, $vars, WATCHDOG_NOTICE);
  }
}