private function LdapUserConfAdmin::addServerMappingFields in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_user/LdapUserConfAdmin.class.php \LdapUserConfAdmin::addServerMappingFields()
Add existing mappings to ldap user provisioning mapping admin form table.
Parameters
drupal form array $form:
enum $direction: LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER or LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY.
Return value
by reference to $form array
1 call to LdapUserConfAdmin::addServerMappingFields()
- LdapUserConfAdmin::drupalForm in ldap_user/
LdapUserConfAdmin.class.php - Generate admin form for ldapUserConf object.
File
- ldap_user/
LdapUserConfAdmin.class.php, line 696
Class
Code
private function addServerMappingFields(&$form, $direction) {
if ($direction == LDAP_USER_PROV_DIRECTION_NONE) {
return;
}
$text = $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ? 'target' : 'source';
$user_attr_options = [
'0' => t('Select') . ' ' . $text,
];
if (!empty($this->synchMapping[$direction])) {
foreach ($this->synchMapping[$direction] as $target_id => $mapping) {
if (!isset($mapping['name']) || isset($mapping['exclude_from_mapping_ui']) && $mapping['exclude_from_mapping_ui']) {
continue;
}
if (isset($mapping['configurable_to_drupal']) && $mapping['configurable_to_drupal'] && $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER || isset($mapping['configurable_to_ldap']) && $mapping['configurable_to_ldap'] && $direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
$user_attr_options[$target_id] = substr($target_id, 1, -1);
}
}
}
if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
$user_attr_options['user_tokens'] = '-- user tokens --';
}
$row = 0;
// 1. non configurable mapping rows.
foreach ($this->synchMapping[$direction] as $target_id => $mapping) {
if (isset($mapping['exclude_from_mapping_ui']) && $mapping['exclude_from_mapping_ui']) {
continue;
}
// Is configurable by ldap_user module (not direction to ldap_user)
if (!$this
->isMappingConfigurable($mapping, 'ldap_user') && ($mapping['direction'] == $direction || $mapping['direction'] == LDAP_USER_PROV_DIRECTION_ALL)) {
$this
->addSynchFormRow($form, 'nonconfigurable', $direction, $mapping, $user_attr_options, $row);
$row++;
}
}
// 2. existing configurable mappings rows.
if (!empty($this->ldapUserSynchMappings[$direction])) {
// Key could be ldap attribute name or user attribute name.
foreach ($this->ldapUserSynchMappings[$direction] as $target_attr_token => $mapping) {
if (isset($mapping['enabled']) && $mapping['enabled'] && $this
->isMappingConfigurable($this->synchMapping[$direction][$target_attr_token], 'ldap_user')) {
$this
->addSynchFormRow($form, 'update', $direction, $mapping, $user_attr_options, $row);
$row++;
}
}
}
// 3. leave 4 rows for adding more mappings.
for ($i = 0; $i < 4; $i++) {
$this
->addSynchFormRow($form, 'add', $direction, NULL, $user_attr_options, $row);
$row++;
}
}