function ldap_user_form_user_register_form_alter in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 8.4 ldap_user/ldap_user.module \ldap_user_form_user_register_form_alter()
- 8.3 ldap_user/ldap_user.module \ldap_user_form_user_register_form_alter()
- 7.2 ldap_user/ldap_user.module \ldap_user_form_user_register_form_alter()
Implements hook_form_FORM_ID_alter(). for user_register_form
File
- ldap_user/
ldap_user.module, line 502 - Module for the LDAP User Entity
Code
function ldap_user_form_user_register_form_alter(&$form, $form_state) {
array_unshift($form['#submit'], 'ldap_user_grab_password_validate');
if (!user_access('administer users')) {
return;
}
$ldap_user_conf = ldap_user_conf();
$ldap_fieldset = array();
$options = array(
LDAP_USER_MANUAL_ACCT_CONFLICT_LDAP_ASSOCIATE => t('Make this an LDAP Associated account. If a related LDAP account can not be found, a validation error will appear and the account will not be created.'),
LDAP_USER_MANUAL_ACCT_CONFLICT_NO_LDAP_ASSOCIATE => t('Do not make this an LDAP Associated account.'),
);
$ldap_fieldset['ldap_user_association'] = array(
'#type' => 'radios',
'#options' => $options,
'#required' => FALSE,
'#title' => t('LDAP Entry Association.'),
);
if ($ldap_user_conf
->provisionEnabled(LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY, LDAP_USER_DRUPAL_USER_PROV_ON_USER_UPDATE_CREATE)) {
$ldap_fieldset['ldap_user_association']['#disabled'] = TRUE;
$ldap_fieldset['ldap_user_association']['#description'] = t('Since "Create
or Synch to Drupal user anytime a Drupal user account is created or updated"
is selected at admin/config/people/ldap/user, this option will have no
effect so its disabled.');
}
elseif ($ldap_user_conf->manualAccountConflict != LDAP_USER_MANUAL_ACCT_CONFLICT_SHOW_OPTION_ON_FORM) {
$ldap_fieldset['ldap_user_association']['#disabled'] = TRUE;
$ldap_fieldset['ldap_user_association']['#description'] = t('To enable
this an LDAP server must be selected for provisioning to Drupal in
admin/config/people/ldap/user and "Show option on user create form..." must be selected.');
}
$ldap_fieldset['ldap_user_create_ldap_acct'] = array(
'#type' => 'checkbox',
'#title' => t('Create corresponding LDAP entry.'),
);
if (!$ldap_user_conf
->provisionEnabled(LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY, LDAP_USER_DRUPAL_USER_PROV_ON_ALLOW_MANUAL_CREATE)) {
$ldap_fieldset['ldap_user_create_ldap_acct']['#disabled'] = TRUE;
$ldap_fieldset['ldap_user_create_ldap_acct']['#description'] = t('To enable
this an LDAP server must be selected for provisioning to Drupal in
admin/config/people/ldap/user and manual creation of LDAP accounts
must be enabled also.');
}
if (count($ldap_fieldset) > 0) {
$form['ldap_user_fields'] = $ldap_fieldset;
$form['ldap_user_fields']['#type'] = 'fieldset';
$form['ldap_user_fields']['#title'] = t('LDAP Options');
$form['ldap_user_fields']['#collapsible'] = TRUE;
$form['ldap_user_fields']['#collapsed'] = FALSE;
}
$form['#validate'][] = 'ldap_user_form_register_form_validate';
$form['#submit'][] = 'ldap_user_form_register_form_submit2';
}