function ldapdata_admin_edit_submit in LDAP integration 6
Same name and namespace in other branches
- 5.2 ldapdata.module \ldapdata_admin_edit_submit()
- 5 ldapdata.module \ldapdata_admin_edit_submit()
Submit hook for the settings form.
File
- ./
ldapdata.admin.inc, line 367 - Module admin page callbacks.
Code
function ldapdata_admin_edit_submit($form, &$form_state) {
$op = $form_state['clicked_button']['#value'];
$values = $form_state['values'];
switch ($op) {
case t('Update'):
if (isset($values['ldapdata_bindpw_clear'])) {
db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_attrs = '%s', ldapdata_filter_php = '%s' WHERE sid = %d", $form_state['ldapdata_mappings'], $form_state['ldapdata_roattrs'], $form_state['ldapdata_rwattrs'], $form_state['ldapdata_attrs'], $form_state['ldapdata_filter_php'], $values['sid']);
if ($values['ldapdata_bindpw_clear']) {
db_query("UPDATE {ldapauth} SET ldapdata_bindpw = '' WHERE sid = %d", $values['sid']);
}
}
else {
db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_binddn = '%s', ldapdata_bindpw = '%s', ldapdata_attrs = '%s', ldapdata_filter_php = '%s' WHERE sid = %d", $form_state['ldapdata_mappings'], $form_state['ldapdata_roattrs'], $form_state['ldapdata_rwattrs'], $values['ldapdata_binddn'], $values['ldapdata_bindpw'], $form_state['ldapdata_attrs'], $form_state['ldapdata_filter_php'], $values['sid']);
}
drupal_set_message(t('The configuration options have been saved.'));
$form_state['redirect'] = 'admin/settings/ldap/ldapdata';
break;
case t('Reset'):
if ($values['confirm'] == 1) {
// Settings reset.
db_query("UPDATE {ldapauth} SET ldapdata_mappings = '', ldapdata_roattrs = '', ldapdata_rwattrs = '', ldapdata_binddn = '', ldapdata_bindpw = '', ldapdata_attrs = '', ldapdata_filter_php = '' WHERE sid = %d", $values['sid']);
drupal_set_message(t('The configuration options have been reset to their default values.'));
}
$form_state['redirect'] = 'admin/settings/ldap/ldapdata';
break;
case t('Test'):
global $_ldapdata_ldap;
if (isset($values['sid']) && _ldapdata_init($values['sid'])) {
// Try to authenticate.
$bind_info = _ldapdata_edition($values['sid']);
if (!$_ldapdata_ldap
->connect($bind_info['dn'], $bind_info['pass'])) {
drupal_set_message(t('Authentication with the LDAP server for the dn %dn and saved password failed.', array(
'%dn' => $bind_info['dn'],
)), 'error');
}
else {
drupal_set_message(t('Authentication with the LDAP server for the dn %dn and saved password succeeded.', array(
'%dn' => $bind_info['dn'],
)));
}
}
else {
drupal_set_message(t('Cannot load server settings. Please save configuration first.'), 'error');
}
break;
}
}