You are here

function simple_ldap_user_translate_drupal_attr_to_ldap in Simple LDAP 7.2

Translate Drupal fields into a format suitable for LDAP.

Invokes HOOK_simple_ldap_field_alter() to handle any fields that are not simple strings copied out to LDAP.

1 call to simple_ldap_user_translate_drupal_attr_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 790
Main simple_ldap_user module file.

Code

function simple_ldap_user_translate_drupal_attr_to_ldap(&$value, $account, $attr) {
  $handlers = simple_ldap_user_get_data_handlers();
  $field_info = field_info_field($attr);
  if (!empty($field_info['type'])) {

    // Get the value using Field API.
    $items = field_get_items('user', $account, $attr);
    $handler = array_key_exists($field_info['type'], $handlers) ? $handlers[$field_info['type']] : $handlers['#default'];
    if (!empty($handler['file'])) {
      require_once $handler['file'];
    }
    $handler['export_callback']($value, $field_info, $items);
  }
}