You are here

function ldap_query_admin_form_submit in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_query/ldap_query.admin.inc \ldap_query_admin_form_submit()
  2. 7 ldap_query/ldap_query.admin.inc \ldap_query_admin_form_submit()

Submit hook for the LDAP server form.

File

ldap_query/ldap_query.admin.inc, line 80
Defines functions for administrative interface for servers.

Code

function ldap_query_admin_form_submit($form, &$form_state) {
  $button = drupal_strtolower($form_state['clicked_button']['#value']);
  $op = $button == 'add' ? 'add' : 'edit';
  $verb = $op == 'edit' ? 'edited' : $op . 'ed';
  ldap_servers_module_load_include('php', 'ldap_query', 'LdapQueryAdmin.class');
  $query = new LdapQueryAdmin($form_state['values']['qid']);

  // Add form data to object and save or create.
  $query
    ->drupalFormSubmit($op, $form_state['values']);
  if ($query
    ->hasError() == FALSE) {
    drupal_set_message(t('LDAP Query %name !verb.', [
      '!verb' => $verb,
      '%name' => $query->name,
    ]), 'status');
    ldap_query_cache_clear();

    // If ($form_state['ldap_warnings'] && $op != 'add') {
    // do nothing, but don't redirect away from form.
    // if there are warnings, want them to see form even if its been saved
    // }
    // else {.
    drupal_goto(LDAP_QUERY_MENU_BASE_PATH . '/query');

    // }.
  }
  else {
    form_set_error($query
      ->errorName(), $query
      ->errorMsg());
    $query
      ->clearError();
  }
  ldap_query_cache_clear();
}