You are here

simple_ldap_user.install in Simple LDAP 7

Same filename and directory in other branches
  1. 7.2 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_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');
}

/**
 * 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.') . ' ' . $t('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');
  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');
  if (!empty($attribute_map)) {
    return t('The "simple_ldap_user_map" variable has changed name and format.') . ' ' . t('The new variable name is "simple_ldap_user_attribute_map", and the format is outlined in simple_ldap_user/README.txt.') . ' ' . t('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');
}

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.