function ldapauth_server_save in LDAP integration 6
Create/Update server settings... updates if $server->sid is set or not. Uses machine_name as the key field for features.
Parameters
Mixed $server Server settings to save as object or array:
Boolean $quiet If true, no success message will be displayed to user.:
Boolean $use_sid If true, use sid to update entry rather than machine name.:
4 calls to ldapauth_server_save()
- ldapauth_admin_form_submit in ./
ldapauth.admin.inc - Submit hook for the LDAP server form.
- ldapauth_admin_import_form_submit in ./
ldapauth.admin.inc - Submit handler to import server settings.
- ldap_servers_features_rebuild in ./
ldapauth.features.inc - Implementation of hook_features_rebuild(). [component_hook]
- ldap_servers_features_revert in ./
ldapauth.features.inc - Implementation of hook_features_revert(). [component_hook]
File
- includes/
ldap.core.inc, line 83 - The core functions that ldapauth supplies for submodules. Will be included by default by ldapauth.
Code
function ldapauth_server_save(&$server, $quiet = FALSE, $use_sid = FALSE) {
if (is_array($server)) {
$server = (object) $server;
$array = TRUE;
}
else {
$array = FALSE;
}
if (isset($server->sid)) {
$type = "updated";
if ($use_sid) {
$update = 'sid';
}
else {
$update = 'machine_name';
}
}
else {
$type = "added";
$update = array();
}
$params = array(
'%name' => $server->name,
'%type' => $type,
);
if ($rc = drupal_write_record('ldapauth', $server, $update)) {
if (!$quiet) {
drupal_set_message(t('Server settings for %name have been %type.', $params));
}
watchdog('ldapauth', 'LDAP Configuration %name has been %type.', $params);
}
else {
drupal_set_message(t('Failed to write the server settings for %name .', array(
'%name' => $server->name,
)), 'warning');
}
if ($array) {
$server = (array) $server;
}
return $rc;
}