You are here

function abjs_experience_form_save_submit in A/B Test JS 7

Saves new and modified experiences into experience table.

1 string reference to 'abjs_experience_form_save_submit'
abjs_experience_form in ./abjs.admin.inc
Generates form for creating and editing experiences.

File

./abjs.admin.inc, line 886
Admin forms to view/add/edit/delete tests, conditions, experiences.

Code

function abjs_experience_form_save_submit($form, &$form_state) {
  global $user;
  if (!empty($form_state['values']['eid'])) {

    // This is a modified experience, so use update.
    db_update('abjs_experience')
      ->fields(array(
      'name' => $form_state['values']['name'],
      'script' => $form_state['values']['script'],
      'changed' => REQUEST_TIME,
      'changed_by' => $user->uid,
    ))
      ->condition('eid', $form_state['values']['eid'], '=')
      ->execute();
    drupal_set_message(t("Successfully updated experience"));
  }
  else {

    // This is a new experience, so use insert.
    db_insert('abjs_experience')
      ->fields(array(
      'name' => $form_state['values']['name'],
      'script' => $form_state['values']['script'],
      'created' => REQUEST_TIME,
      'created_by' => $user->uid,
      'changed' => REQUEST_TIME,
      'changed_by' => $user->uid,
    ))
      ->execute();
    drupal_set_message(t("Successfully saved new experience"));
  }
  $form_state['redirect'] = array(
    '/admin/config/user-interface/abjs/experiences',
  );
}