You are here

function ldap_query_admin_form_submit in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_query/ldap_query.admin.inc \ldap_query_admin_form_submit()
  2. 7.2 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 89
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_server_module_load_include('php', 'ldap_query', 'LdapQueryAdmin.class');
  $query = new LdapQueryAdmin($form_state['values']['qid']);
  $query
    ->drupalFormSubmit($op, $form_state['values']);

  // add form data to object and save or create
  if ($query
    ->hasError() == FALSE) {
    drupal_set_message(t('LDAP Query %name !verb.', array(
      '!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($server
      ->errorName(), $server
      ->errorMsg());
    $server
      ->clearError();
  }
  ldap_query_cache_clear();
}