You are here

ldapdata.install in LDAP integration 6

Same filename and directory in other branches
  1. 5 ldapdata.install

ldapdata module installation and upgrade code.

File

ldapdata.install
View source
<?php

/**
 * @file
 * ldapdata module installation and upgrade code.
 */

//////////////////////////////////////////////////////////////////////////////

// Core API hooks

/**
 * Implementation of hook_requirements().
 * Checks that ldap extension is installed during install phase only.
 *
 * @param string $phase
 */
function ldapdata_requirements($phase) {
  if ($phase == 'install') {
    $ldap_extension_loaded = extension_loaded('ldap');
    $t = get_t();
    $requirements = array(
      'ldapdata' => array(
        'title' => $t('PHP LDAP Extension'),
        'description' => $ldap_extension_loaded ? $t('extension enabled') : $t('The PHP LDAP extension is missing or not enabled.  This is required by the LDAP Integration suite.'),
        'severity' => $ldap_extension_loaded ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      ),
    );
    return $requirements;
  }
}

/**
 * Implementation of hook_install().
 */
function ldapdata_install() {

  // We're adding to an existing table, not creating a new one.
  $ret = array();
  db_add_field($ret, 'ldapauth', 'ldapdata_binddn', array(
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_bindpw', array(
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_rwattrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_roattrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_mappings', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_attrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_filter_php', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function ldapdata_uninstall() {

  // We're removing fileds from an existing table, not deleting a whole one.
  $ret = array();
  if (db_table_exists('ldapauth')) {
    db_drop_field($ret, 'ldapauth', 'ldapdata_binddn');
    db_drop_field($ret, 'ldapauth', 'ldapdata_bindpw');
    db_drop_field($ret, 'ldapauth', 'ldapdata_rwattrs');
    db_drop_field($ret, 'ldapauth', 'ldapdata_roattrs');
    db_drop_field($ret, 'ldapauth', 'ldapdata_mappings');
    db_drop_field($ret, 'ldapauth', 'ldapdata_attrs');
    db_drop_field($ret, 'ldapauth', 'ldapdata_filter_php');
  }

  // Remove variables
  variable_del('ldapdata_sync');
  variable_del('ldapauth_disable_picture_change');
  return $ret;
}
function ldapdata_update_6001() {
  $ret = array();
  db_add_field($ret, 'ldapauth', 'ldapdata_attrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapdata_filter_php', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  return $ret;
}
function ldapdata_update_6002() {
  $ret = array();
  db_change_field($ret, 'ldapauth', 'ldapdata_rwattrs', 'ldapdata_rwattrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'ldapauth', 'ldapdata_roattrs', 'ldapdata_roattrs', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'ldapauth', 'ldapdata_mappings', 'ldapdata_mappings', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  return $ret;
}

Functions

Namesort descending Description
ldapdata_install Implementation of hook_install().
ldapdata_requirements Implementation of hook_requirements(). Checks that ldap extension is installed during install phase only.
ldapdata_uninstall Implementation of hook_uninstall().
ldapdata_update_6001
ldapdata_update_6002