function ldapauth_admin_import_form_validate in LDAP integration 6
Validate a server settings import.
File
- ./
ldapauth.admin.inc, line 783 - Module admin page callbacks.
Code
function ldapauth_admin_import_form_validate($form, &$form_state) {
// Run the import code, which should return a serialized $preset object.
$ldapserver = unserialize(drupal_eval($form_state['values']['import']));
if (empty($ldapserver) || !is_object($ldapserver) || empty($ldapserver->name)) {
form_set_error('import', t('The submitted preset code could not be interperated.'));
}
elseif (isset($ldapserver->sid)) {
form_set_error('import', t('Imported server can not have an sid field value,'));
}
elseif (ldapauth_server_load_by_name($ldapserver->name)) {
form_set_error('import', t('A server with the name, @server already exists.', array(
'@server' => $ldapserver->name,
)));
}
elseif (ldapauth_server_load($ldapserver->machine_name)) {
form_set_error('import', t('A server with the machine name, @server already exists.', array(
'@server' => $ldapserver->machine_name,
)));
}
else {
// Pass the parsed object on to the submit handler.
$form_state['values']['import_parsed'] = $ldapserver;
}
}