function simple_ldap_user_base_field_to_ldap in Simple LDAP 7.2
Convert a field defined by the user module to a format suitable for LDAP
Parameters
array $ldap_edit: An array of values to be handed to LDAP. Similar in function to user_save()'s $edit parameter, but different in syntax.
object $account: The Drupal user object being written to LDAP
string $drupal_field_name: The name of the field to be converted.
1 call to simple_ldap_user_base_field_to_ldap()
- simple_ldap_user_sync_user_to_ldap in simple_ldap_user/
simple_ldap_user.module - Synchronizes Drupal user properties to LDAP.
File
- simple_ldap_user/
simple_ldap_user.module, line 853 - Main simple_ldap_user module file.
Code
function simple_ldap_user_base_field_to_ldap(&$ldap_edit, $account, $drupal_field_name) {
$ldap_user = SimpleLdapUser::singleton($account->name);
switch ($drupal_field_name) {
case 'access':
case 'login':
case 'created':
if (!empty($account->{$drupal_field_name})) {
$tz = date_default_timezone_get();
date_default_timezone_set('UTC');
$ldap_edit[] = date('YmdHis', $account->{$drupal_field_name}) . 'Z';
date_default_timezone_set($tz);
}
break;
case 'picture':
if (is_object($account->picture)) {
$file = $account->picture;
}
else {
$file = file_load(empty($account->picture) ? 0 : $account->picture);
}
if (!empty($file)) {
$ldap_edit[] = file_get_contents($file->uri);
}
break;
case 'status':
$status = property_exists($account, 'simple_ldap_user_drupal_status') ? $account->simple_ldap_user_drupal_status : $account->status;
$ldap_edit[] = $status ? "1" : "0";
break;
default:
$ldap_edit[] = $account->{$drupal_field_name};
}
}