You are here

simple_ldap.install in Simple LDAP 7.2

Same filename and directory in other branches
  1. 7 simple_ldap.install

simple_ldap module installation.

File

simple_ldap.install
View source
<?php

/**
 * @file
 * simple_ldap module installation.
 */

/**
 * Implements hook_uninstall().
 */
function simple_ldap_uninstall() {
  variable_del('simple_ldap_host');
  variable_del('simple_ldap_port');
  variable_del('simple_ldap_starttls');
  variable_del('simple_ldap_binddn');
  variable_del('simple_ldap_bindpw');
  variable_del('simple_ldap_basedn');
  variable_del('simple_ldap_readonly');
  variable_del('simple_ldap_pagesize');
  variable_del('simple_ldap_debug');
  variable_del('simple_ldap_opt_referrals');
}

/**
 * Implements hook_requirements().
 */
function simple_ldap_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();

  // Make sure the PHP LDAP extension is loaded.
  if (extension_loaded('ldap')) {
    $requirements['php.ldap'] = array(
      'title' => $t('PHP LDAP extension'),
      'severity' => extension_loaded('ldap') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $t('Enabled'),
      'severity' => REQUIREMENT_OK,
      'description' => NULL,
    );
  }
  else {
    $requirements['php.ldap'] = array(
      'title' => $t('PHP LDAP extension'),
      'severity' => extension_loaded('ldap') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => NULL,
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('No PHP LDAP extension found.  Please install the extension and try enabling the module again.'),
    );
  }

  // Make sure an LDAP server is configured, and Drupal can connect to it.
  if ($phase == 'runtime') {
    if (simple_ldap_configured()) {
      $server = SimpleLdapServer::singleton();
      $bind = $server
        ->bind();
      if ($bind) {
        $value = $t('Successfully bound to @host.', array(
          '@host' => $server->host,
        ));
        $severity = REQUIREMENT_OK;
      }
      else {
        $value = $t('Failed to bind to @host.', array(
          '@host' => $server->host,
        ));
        $severity = REQUIREMENT_ERROR;
      }
    }
    else {
      $value = $t('Simple LDAP Server is not configured.');
      $severity = REQUIREMENT_WARNING;
    }
    $requirements['ldap.server'] = array(
      'title' => $t('Simple LDAP Server'),
      'value' => $value,
      'severity' => $severity,
      'description' => NULL,
    );
  }
  return $requirements;
}

/**
 * Update configuration variables.
 */
function simple_ldap_update_7100(&$sandbox) {
  variable_set('simple_ldap_opt_referrals', variable_get('simple_ldap_opt_referrals', TRUE));
}

Functions

Namesort descending Description
simple_ldap_requirements Implements hook_requirements().
simple_ldap_uninstall Implements hook_uninstall().
simple_ldap_update_7100 Update configuration variables.