You are here

simple_ldap_user.install in Simple LDAP 7.2

Same filename and directory in other branches
  1. 7 simple_ldap_user/simple_ldap_user.install

simple_ldap_user module installation.

File

simple_ldap_user/simple_ldap_user.install
View source
<?php

/**
 * @file
 * simple_ldap_user module installation.
 */

/**
 * Implements hook_enable().
 */
function simple_ldap_user_enable() {
  variable_set('password_inc', drupal_get_path('module', 'simple_ldap_user') . '/simple_ldap_user.password.inc');
}

/**
 * Implements hook_disable().
 */
function simple_ldap_user_disable() {
  $password_inc = drupal_get_path('module', 'simple_ldap_user') . '/simple_ldap_user.password.inc';
  if (variable_get('password_inc') == $password_inc) {
    variable_del('password_inc');
  }
}

/**
 * Implements hook_uninstall().
 */
function simple_ldap_user_uninstall() {
  variable_del('simple_ldap_user_basedn');
  variable_del('simple_ldap_user_scope');
  variable_del('simple_ldap_user_objectclass');
  variable_del('simple_ldap_user_auxiliaryclasses');
  variable_del('simple_ldap_user_attribute_name');
  variable_del('simple_ldap_user_attribute_mail');
  variable_del('simple_ldap_user_attribute_pass');
  variable_del('simple_ldap_user_attribute_rdn');
  variable_del('simple_ldap_user_password_hash');
  variable_del('simple_ldap_user_filter');
  variable_del('simple_ldap_user_source');
  variable_del('simple_ldap_user_sync');
  variable_del('simple_ldap_user_extra_attrs');
}

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

  // Ensure translations don't break during installation.
  $t = get_t();
  if ($phase == 'runtime') {
    $expected = drupal_get_path('module', 'simple_ldap_user') . '/simple_ldap_user.password.inc';
    $password_inc = variable_get('password_inc');
    $requirements['password_inc'] = array(
      'title' => 'password_inc',
      'value' => $password_inc,
      'severity' => $password_inc == $expected ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'description' => $t('Simple LDAP User requires overrides to some of the Drupal password hashing functions.  If the password_inc variable is not set to the file provided by Simple LDAP User, LDAP authentication will not work.'),
    );
  }
  return $requirements;
}

/**
 * Update configuration variables.
 */
function simple_ldap_user_update_7100(&$sandbox) {

  // simple_ldap_user_objectclass should be an array.
  $objectclass = variable_get('simple_ldap_user_objectclass', NULL);
  if (!is_array($objectclass)) {
    variable_set('simple_ldap_user_objectclass', array(
      $objectclass,
    ));
  }

  // simple_ldap_user_map has changed name and format.
  $attribute_map = variable_get('simple_ldap_user_map', array());
  if (!empty($attribute_map)) {
    return t('The "simple_ldap_user_map" variable has changed name and format.  The new variable name is "simple_ldap_user_attribute_map", and the format is outlined in simple_ldap_user/README.txt.  Please update settings.php accordingly.');
  }
}

/**
 * Remove the simple_ldap_user_delete variable.
 */
function simple_ldap_user_update_7101(&$sandbox) {
  variable_del('simple_ldap_user_delete');
}

/**
 * Did we say simple_ldap_user_objectclass should be an array?  Yeah, no.
 */
function simple_ldap_user_update_7102(&$sandbox) {
  $user_object_class = variable_get('simple_ldap_user_objectclass', NULL);
  if (is_array($user_object_class)) {
    variable_set('simple_ldap_user_objectclass', $user_object_class[0]);
  }
}

Functions

Namesort descending Description
simple_ldap_user_disable Implements hook_disable().
simple_ldap_user_enable Implements hook_enable().
simple_ldap_user_requirements Implements hook_requirements().
simple_ldap_user_uninstall Implements hook_uninstall().
simple_ldap_user_update_7100 Update configuration variables.
simple_ldap_user_update_7101 Remove the simple_ldap_user_delete variable.
simple_ldap_user_update_7102 Did we say simple_ldap_user_objectclass should be an array? Yeah, no.