You are here

ldapgroups.install in LDAP integration 6

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

ldapgroups module installation and upgrade code.

File

ldapgroups.install
View source
<?php

/**
 * @file
 * ldapgroups 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 ldapgroups_requirements($phase) {
  if ($phase == 'install') {
    $ldap_extension_loaded = extension_loaded('ldap');
    $t = get_t();
    $requirements = array(
      'ldapgroups' => 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 ldapgroups_install() {

  // We're adding to an existing table, not creating a new one.
  $ret = array();
  db_add_field($ret, 'ldapauth', 'ldapgroups_in_dn', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_dn_attribute', array(
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_attr', array(
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_in_attr', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_as_entries', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_entries', array(
    'type' => 'text',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_entries_attribute', array(
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_mappings', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_mappings_filter', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_filter_php', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_groups', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function ldapgroups_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', 'ldapgroups_in_dn');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_dn_attribute');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_attr');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_in_attr');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_as_entries');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_entries');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_entries_attribute');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_mappings');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_mappings_filter');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_filter_php');
    db_drop_field($ret, 'ldapauth', 'ldapgroups_groups');
  }
  return $ret;
}
function ldapgroups_update_6001() {
  $ret = array();
  db_add_field($ret, 'ldapauth', 'ldapgroups_mappings', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_mappings_filter', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_filter_php', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'ldapauth', 'ldapgroups_groups', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  return $ret;
}

Functions

Namesort descending Description
ldapgroups_install Implementation of hook_install().
ldapgroups_requirements Implementation of hook_requirements(). Checks that ldap extension is installed during install phase only.
ldapgroups_uninstall Implementation of hook_uninstall().
ldapgroups_update_6001