You are here

function abjs_condition_form_save_submit in A/B Test JS 7

Saves new and modified conditions into condition table.

1 string reference to 'abjs_condition_form_save_submit'
abjs_condition_form in ./abjs.admin.inc
Generates a form for creating and editing conditions.

File

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

Code

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

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

    // This is a new condition, so use insert.
    db_insert('abjs_condition')
      ->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 condition"));
  }
  $form_state['redirect'] = array(
    '/admin/config/user-interface/abjs/conditions',
  );
}