function _ldapdata_user_update_content_profile in LDAP integration 6
Find out which content profile attributes should be synced back to LDAP.
Parameters
$node: A content profile node being updated.
$account: A user object.
Return value
An associated array of attributes to write to LDAP.
1 call to _ldapdata_user_update_content_profile()
- ldapdata_node_update in ./
ldapdata.module - Drupal 7 hook_node_update. Handles the case of content profile updates being written back to ldap if needed.
File
- ./
ldapdata.module, line 1141 - ldapdata provides data maping against ldap server.
Code
function _ldapdata_user_update_content_profile(&$node, &$account) {
if (_ldapdata_ldap_info($account, 'mapping_type') != LDAPDATA_MAP_ATTRIBUTES) {
return array();
}
$ldap_drupal_reverse_mappings = _ldapdata_reverse_mappings($account->ldap_config);
// Retrieve profile fields list.
$content_profile_fields = _ldapdata_retrieve_content_profile_fields();
// Compare against $edit list.
$writeout = array();
foreach ($content_profile_fields as $key => $field_name) {
$field = $node->{$key};
if (isset($field) && isset($ldap_drupal_reverse_mappings[$key])) {
// Determine what kind of field we are dealing with
// TODO: Handle multiple value fields
$field_lookup = content_fields($key);
$field_type = $field_lookup['type'];
switch ($field_type) {
case 'email':
$writeout[$ldap_drupal_reverse_mappings[$key]] = $field[0]['email'];
break;
case 'content_taxonomy':
// Convert tid to term name since that is what the _load_user does
if ($term = taxonomy_get_term($field[0]['value'])) {
$writeout[$ldap_drupal_reverse_mappings[$key]] = $term;
}
break;
default:
$writeout[$ldap_drupal_reverse_mappings[$key]] = $field[0]['value'];
}
}
}
return $writeout;
}