You are here

function ldap_user_test_form in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_user/ldap_user.test_form.inc \ldap_user_test_form()

Implements the LDAP user test page.

Parameters

$form_state: A form state array.

$op: An operatin - add or edit.

$sid: A LDAP server ID.

Return value

The form structure.

1 string reference to 'ldap_user_test_form'
ldap_user_menu in ldap_user/ldap_user.module
Implements hook_menu().

File

ldap_user/ldap_user.test_form.inc, line 21

Code

function ldap_user_test_form($form, &$form_state, $op = NULL) {
  $username = @$_SESSION['ldap_user_test_form']['testing_drupal_username'];
  $form['#prefix'] = t('<h1>Test LDAP User Configuration</h1>');
  $form['#prefix'] .= t('This form simply tests an LDAP User configuration against an individual ldap or drupal user.
    It makes no changes to the drupal or ldap user.');
  $form['testing_drupal_username'] = array(
    '#type' => 'textfield',
    '#title' => t('Testing Drupal Username'),
    '#default_value' => $username,
    '#required' => 1,
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('This is optional and used for testing this server\'s configuration against an actual username.  The user need not exist in Drupal and testing will not affect the user\'s LDAP or Drupal Account.'),
  );
  $form['test_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Testing Mode'),
    '#required' => 0,
    '#default_value' => isset($_SESSION['ldap_user_test_form']['test_mode']) ? $_SESSION['ldap_user_test_form']['test_mode'] : 'query',
    '#options' => array(
      'query' => t('Test Query.  Will not alter anything in drupal or LDAP'),
      'execute' => t('Execute Action.  Will perform provisioning configured for events below.  If this is selected only one action should be selected below'),
    ),
  );
  $synch_trigger_options = ldap_user_synch_triggers_key_values();
  $selected_actions = isset($_SESSION['ldap_user_test_form']['action']) ? $_SESSION['ldap_user_test_form']['action'] : array();
  $form['action'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Actions/Event Handlers to Test'),
    '#required' => 0,
    '#default_value' => $selected_actions,
    '#options' => $synch_trigger_options,
    '#states' => array(
      'visible' => array(
        // action to take.
        ':input[name="wsEnabled"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'test',
    '#weight' => 100,
  );
  return $form;
}