You are here

function ldapauth_admin_form_submit in LDAP integration 5.2

Same name and namespace in other branches
  1. 5 ldapauth.module \ldapauth_admin_form_submit()
  2. 6 ldapauth.admin.inc \ldapauth_admin_form_submit()

* Submit the contact category page for submission

File

./ldapauth.module, line 476

Code

function ldapauth_admin_form_submit($form_id, $form_values) {

  // set the checking order
  if (arg(3) == 'add') {
    if (db_fetch_object(db_query("SELECT name FROM {ldapauth} WHERE name = '%s'", $form_values['name']))) {
      form_set_error('name', t('An LDAP config with that name already exists.'));
    }
    db_query("INSERT INTO {ldapauth} (name, status, server, port, tls, encrypted, basedn, user_attr, mail_attr, binddn, bindpw) VALUES ('%s', '%d', '%s', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s')", $form_values['name'], 1, $form_values['server'], $form_values['port'], $form_values['tls'], $form_values['encrypted'], $form_values['basedn'], $form_values['user_attr'], $form_values['mail_attr'], $form_values['binddn'], $form_values['bindpw']);
    drupal_set_message(t('LDAP Configuration %config has been added.', array(
      '%config' => $form_values['name'],
    )));
    watchdog('ldap', t('ldapauth: ldap config %config added.', array(
      '%config' => $form_values['name'],
    )));
  }
  else {
    if (!$form_values['bindpw_clear'] && $form_values['bindpw']) {
      db_query("UPDATE {ldapauth} SET name = '%s', server = '%s', port = '%d', tls = '%d', encrypted = '%d', basedn = '%s', user_attr = '%s', mail_attr = '%s', binddn = '%s', bindpw = '%s', bindpw_clear = '%d' WHERE name = '%s'", $form_values['name'], $form_values['server'], $form_values['port'], $form_values['tls'], $form_values['encrypted'], $form_values['basedn'], $form_values['user_attr'], $form_values['mail_attr'], $form_values['binddn'], $form_values['bindpw'], $form_values['bindpw_clear'], $form_values['old-name']);
    }
    else {

      // set the clear password switch
      db_query("UPDATE {ldapauth} SET name = '%s', server = '%s', port = '%d', tls = '%d', encrypted = '%d', basedn = '%s', user_attr = '%s', mail_attr = '%s', binddn = '%s', bindpw_clear = '%d' WHERE name = '%s'", $form_values['name'], $form_values['server'], $form_values['port'], $form_values['tls'], $form_values['encrypted'], $form_values['basedn'], $form_values['user_attr'], $form_values['mail_attr'], $form_values['binddn'], $form_values['bindpw_clear'], $form_values['old-name']);
    }
    drupal_set_message(t('LDAP Configuration %config has been updated.', array(
      '%config' => $form_values['name'],
    )));
    watchdog('ldap', t('ldapauth: ldap config %config updated.', array(
      '%config' => $form_values['name'],
    )));
  }
  return 'admin/settings/ldapauth';
}