private function LdapUserConfAdmin::addSynchFormRow in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_user/LdapUserConfAdmin.class.php \LdapUserConfAdmin::addSynchFormRow()
Add mapping form row to ldap user provisioning mapping admin form table.
Parameters
drupal form array $form:
string $action: is 'add', 'update', or 'nonconfigurable'.
enum $direction: LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER or LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY.
array $mapping: is current setting for updates or nonconfigurable items.
array $user_attr_options: of drupal user target options.
int $row: is current row in table.
Return value
by reference to $form
1 call to LdapUserConfAdmin::addSynchFormRow()
- LdapUserConfAdmin::addServerMappingFields in ldap_user/
LdapUserConfAdmin.class.php - Add existing mappings to ldap user provisioning mapping admin form table.
File
- ldap_user/
LdapUserConfAdmin.class.php, line 774
Class
Code
private function addSynchFormRow(&$form, $action, $direction, $mapping, $user_attr_options, $row) {
$id_prefix = $direction . '__';
$id = $id_prefix . 'sm__remove__' . $row;
$form[$id] = [
'#id' => $id,
'#row' => $row,
'#col' => 0,
'#type' => 'checkbox',
'#default_value' => NULL,
'#disabled' => $action == 'add' || $action == 'nonconfigurable',
];
$id = $id_prefix . 'sm__convert__' . $row;
$form[$id] = [
'#id' => $id,
'#row' => $row,
'#col' => $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ? 2 : 3,
'#type' => 'checkbox',
'#default_value' => isset($mapping['convert']) ? $mapping['convert'] : '',
'#disabled' => $action == 'nonconfigurable',
'#attributes' => [
'class' => [
'convert',
],
],
];
$id = $id_prefix . 'sm__ldap_attr__' . $row;
$col = $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ? 1 : 4;
if ($action == 'nonconfigurable') {
$form[$id] = [
'#id' => $id,
'#row' => $row,
'#col' => $col,
'#type' => 'item',
'#markup' => isset($mapping['source']) ? $mapping['source'] : '?',
'#attributes' => [
'class' => [
'source',
],
],
];
}
else {
$form[$id] = [
'#id' => $id,
'#row' => $row,
'#col' => $col,
'#type' => 'textfield',
'#default_value' => isset($mapping['ldap_attr']) ? $mapping['ldap_attr'] : '',
'#size' => 20,
'#maxlength' => 255,
'#attributes' => [
'class' => [
'ldap-attr',
],
],
];
}
$user_attr_input_id = $id_prefix . 'sm__user_attr__' . $row;
$col = $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ? 3 : 1;
if ($action == 'nonconfigurable') {
$form[$user_attr_input_id] = [
'#id' => $user_attr_input_id,
'#row' => $row,
'#col' => $col,
'#type' => 'item',
'#markup' => isset($mapping['name']) ? $mapping['name'] : '?',
];
}
else {
$form[$user_attr_input_id] = [
'#id' => $user_attr_input_id,
'#row' => $row,
'#col' => $col,
'#type' => 'select',
'#default_value' => isset($mapping['user_attr']) ? $mapping['user_attr'] : '',
'#options' => $user_attr_options,
];
}
if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
$id = $id_prefix . 'sm__user_tokens__' . $row;
$form[$id] = [
'#id' => $id,
'#row' => $row,
'#col' => 2,
'#type' => 'textfield',
'#default_value' => isset($mapping['user_tokens']) ? $mapping['user_tokens'] : '',
'#size' => 40,
'#maxlength' => 255,
'#disabled' => $action == 'nonconfigurable',
'#states' => [
'visible' => [
':input[name="' . $user_attr_input_id . '"]' => [
'value' => 'user_tokens',
],
],
],
'#attributes' => [
'class' => [
'tokens',
],
],
];
}
$form['#storage']['synch_mapping_fields'][$direction][$row] = [
'action' => $action,
'direction' => $direction,
];
$id = $id_prefix . 'sm__configurable_to_drupal__' . $row;
$form[$id] = [
'#id' => $id,
'#type' => 'hidden',
'#default_value' => $action != 'nonconfigurable',
];
$col = $direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ? 5 : 4;
$synchEvents = $direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ? $this->provisionsDrupalEvents : $this->provisionsLdapEvents;
foreach ($synchEvents as $prov_event => $prov_event_name) {
$col++;
$id = $id_prefix . join('__', [
'sm',
$prov_event,
$row,
]);
$form[$id] = [
'#id' => $id,
'#type' => 'checkbox',
'#default_value' => isset($mapping['prov_events']) ? (int) in_array($prov_event, $mapping['prov_events']) : '',
'#row' => $row,
'#col' => $col,
'#disabled' => !$this
->provisionEventConfigurable($prov_event, $mapping) || $action == 'nonconfigurable',
'#attributes' => [
'class' => [
'synch-method',
],
],
];
}
}