You are here

public function LdapAuthenticationConfAdmin::drupalForm in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_authentication/LdapAuthenticationConfAdmin.class.php \LdapAuthenticationConfAdmin::drupalForm()
  2. 7.2 ldap_authentication/LdapAuthenticationConfAdmin.class.php \LdapAuthenticationConfAdmin::drupalForm()

File

ldap_authentication/LdapAuthenticationConfAdmin.class.php, line 251

Class

LdapAuthenticationConfAdmin

Code

public function drupalForm() {
  if (count($this->authenticationServersOptions) == 0) {
    $message = ldap_servers_no_enabled_servers_msg('configure LDAP Authentication');
    $form['intro'] = array(
      '#type' => 'item',
      '#markup' => t('<h1>LDAP Authentication Settings</h1>') . $message,
    );
    return $form;
  }
  $tokens = array();

  // not sure what the tokens would be for this form?
  $form['intro'] = array(
    '#type' => 'item',
    '#markup' => t('<h1>LDAP Authentication Settings</h1>'),
  );
  $form['logon'] = array(
    '#type' => 'fieldset',
    '#title' => t('Logon Options'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['logon']['authenticationMode'] = array(
    '#type' => 'radios',
    '#title' => t('Allowable Authentications'),
    '#required' => 1,
    '#default_value' => $this->authenticationMode,
    '#options' => $this->authenticationModeOptions,
  );
  $form['logon']['authenticationServers'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Authentication LDAP Server Configurations'),
    '#required' => FALSE,
    '#default_value' => $this->sids,
    '#options' => $this->authenticationServersOptions,
    '#description' => $this->authenticationServersDescription,
  );
  $form['login_UI'] = array(
    '#type' => 'fieldset',
    '#title' => t('User Login Interface'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['login_UI']['loginUIUsernameTxt'] = array(
    '#type' => 'textfield',
    '#title' => t('Username Description Text'),
    '#required' => 0,
    '#default_value' => $this->loginUIUsernameTxt,
    '#description' => $this->loginUIUsernameTxtDescription,
  );
  $form['login_UI']['loginUIPasswordTxt'] = array(
    '#type' => 'textfield',
    '#title' => t('Password Description Text'),
    '#required' => 0,
    '#default_value' => $this->loginUIPasswordTxt,
    '#description' => $this->loginUIPasswordTxtDescription,
  );
  $form['login_UI']['ldapUserHelpLinkUrl'] = array(
    '#type' => 'textfield',
    '#title' => t('LDAP Account User Help URL'),
    '#required' => 0,
    '#default_value' => $this->ldapUserHelpLinkUrl,
    '#description' => $this->ldapUserHelpLinkUrlDescription,
  );
  $form['login_UI']['ldapUserHelpLinkText'] = array(
    '#type' => 'textfield',
    '#title' => t('LDAP Account User Help Link Text'),
    '#required' => 0,
    '#default_value' => $this->ldapUserHelpLinkText,
    '#description' => $this->ldapUserHelpLinkTextDescription,
  );
  $form['restrictions'] = array(
    '#type' => 'fieldset',
    '#title' => t('LDAP User "Whitelists" and Restrictions'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['restrictions']['allowOnlyIfTextInDn'] = array(
    '#type' => 'textarea',
    '#title' => t('Allow Only Text Test'),
    '#default_value' => $this
      ->arrayToLines($this->allowOnlyIfTextInDn),
    '#cols' => 50,
    '#rows' => 3,
    '#description' => t($this->allowOnlyIfTextInDnDescription, $tokens),
  );
  $form['restrictions']['excludeIfTextInDn'] = array(
    '#type' => 'textarea',
    '#title' => t('Excluded Text Test'),
    '#default_value' => $this
      ->arrayToLines($this->excludeIfTextInDn),
    '#cols' => 50,
    '#rows' => 3,
    '#description' => t($this->excludeIfTextInDnDescription, $tokens),
  );
  $form['restrictions']['allowTestPhp'] = array(
    '#type' => 'textarea',
    '#title' => t('PHP to Test for Allowed LDAP Users'),
    '#default_value' => $this->allowTestPhp,
    '#cols' => 50,
    '#rows' => 3,
    '#description' => t($this->allowTestPhpDescription, $tokens),
    '#disabled' => (bool) (!module_exists('php')),
  );
  if (!module_exists('php')) {
    $form['restrictions']['allowTestPhp']['#title'] .= ' <em>' . t('php module currently disabled') . '</em>';
  }
  $form['restrictions']['excludeIfNoAuthorizations'] = array(
    '#type' => 'checkbox',
    '#title' => t('New and lightly tested feature. Use with caution!  Requires LDAP Authorization to be enabled and configured.  Deny access to users without Ldap Authorization Module authorization mappings such as Drupal roles.'),
    '#default_value' => $this->excludeIfNoAuthorizations,
    '#description' => t($this->excludeIfNoAuthorizationsDescription, $tokens),
    '#disabled' => (bool) (!module_exists('ldap_authorization')),
  );
  $form['drupal_accounts'] = array(
    '#type' => 'fieldset',
    '#title' => t('Drupal User Account Creation'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['drupal_accounts']['loginConflictResolve'] = array(
    '#type' => 'radios',
    '#title' => t('Existing Drupal User Account Conflict'),
    '#required' => 1,
    '#default_value' => $this->loginConflictResolve,
    '#options' => $this->loginConflictOptions,
    '#description' => t($this->loginConflictResolveDescription),
  );
  $form['drupal_accounts']['acctCreation'] = array(
    '#type' => 'radios',
    '#title' => t('Account Creation for LDAP Authenticated Users'),
    '#required' => 1,
    '#default_value' => $this->acctCreation,
    '#options' => $this->acctCreationOptions,
    '#description' => t($this->acctCreationDescription),
  );
  $form['email'] = array(
    '#type' => 'fieldset',
    '#title' => t('Email'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['email']['emailOption'] = array(
    '#type' => 'radios',
    '#title' => t('Email Behavior'),
    '#required' => 1,
    '#default_value' => $this->emailOption,
    '#options' => $this->emailOptionOptions,
  );
  $form['email']['emailUpdate'] = array(
    '#type' => 'radios',
    '#title' => t('Email Update'),
    '#required' => 1,
    '#default_value' => $this->emailUpdate,
    '#options' => $this->emailUpdateOptions,
  );

  /**
   * Begin single sign-on settings
   */
  $form['sso'] = array(
    '#type' => 'fieldset',
    '#title' => t('Single Sign-On'),
    '#collapsible' => TRUE,
    '#collapsed' => (bool) (!$this->ssoEnabled),
  );

  /**
      $form['sso']['ssoEnabled'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable Single Sign-On'),
        '#description' => t($this->ssoEnabledDescription),
        '#default_value' => $this->ssoEnabled,
        '#disabled' => (boolean)(!module_exists('ldap_sso')),
        );
  **/
  if ($this->ssoEnabled) {
    $form['sso']['enabled'] = array(
      '#type' => 'markup',
      '#markup' => $this->ssoEnabledDescription,
    );
  }
  else {
    $form['sso']['disabled'] = array(
      '#type' => 'markup',
      '#markup' => '<p><em>' . t('LDAP Single Sign-On module must be enabled for options below to work.') . ' ' . t('It is currently disabled.') . ' ' . l('Modules Form', 'admin/modules') . '</p></em>',
    );
  }
  $form['sso']['ssoRemoteUserStripDomainName'] = array(
    '#type' => 'checkbox',
    '#title' => t('Strip REMOTE_USER domain name'),
    '#description' => t($this->ssoRemoteUserStripDomainNameDescription),
    '#default_value' => $this->ssoRemoteUserStripDomainName,
    '#disabled' => (bool) (!$this->ssoEnabled),
  );
  $form['sso']['seamlessLogin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn on automated single sign-on'),
    '#description' => t($this->seamlessLogInDescription),
    '#default_value' => $this->seamlessLogin,
    '#disabled' => (bool) (!$this->ssoEnabled),
  );
  $form['sso']['cookieExpire'] = array(
    '#type' => 'select',
    '#title' => t('Cookie Lifetime'),
    '#description' => t($this->cookieExpireDescription),
    '#default_value' => $this->cookieExpire,
    '#options' => $this->cookieExpirePeriod,
    '#disabled' => (bool) (!$this->ssoEnabled),
  );
  $form['sso']['ldapImplementation'] = array(
    '#type' => 'select',
    '#title' => t('Authentication Mechanism'),
    '#description' => t($this->ldapImplementationDescription),
    '#default_value' => $this->ldapImplementation,
    '#options' => $this->ldapImplementationOptions,
    '#disabled' => (bool) (!$this->ssoEnabled),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
  );
  return $form;
}