You are here

ldap_authorization.install in Lightweight Directory Access Protocol (LDAP) 7

Install, update and uninstall functions for the LDAP authorization module.

File

ldap_authorization/ldap_authorization.install
View source
<?php

// $Id: ldap_authorization.install,v 1.1.4.2 2011/02/08 06:01:00 johnbarclay Exp $

/**
 * @file
 * Install, update and uninstall functions for the LDAP authorization module.
 */

/**
 * Implements hook_requirements().
 */
function ldap_authorization_requirements($phase) {
  $requirements = array();
  if ($phase != "install" && db_field_exists('ldapauth', 'ldapgroups_in_dn')) {
    $requirements['ldap_authorization_ldap_integration']['title'] = t('LDAP Integration LDAP Groups Upgrade Concern');
    $requirements['ldap_authorization_ldap_integration']['severity'] = REQUIREMENT_WARNING;
    $requirements['ldap_authorization_ldap_integration']['value'] = NULL;
    $requirements['ldap_authorization_ldap_integration']['description'] = t('Upgrade from Drupal 6 LDAP Groups to Drupal 7
      LDAP Authorization is not automatic.  LDAP Authorization will need to be configured by hand.
      The authorization options are different and automated updgrade is not possible.
      See also. See http://drupal.org/node/1023016, http://drupal.org/node/1183192.
      This message will go away when the ldapauth database table is removed.');
  }

  // check that ldapauth not installed.
  return $requirements;
}

/**
 * Implements hook_schema().
 */
function ldap_authorization_schema() {
  $schema['ldap_authorization'] = array(
    'export' => array(
      'key' => 'consumer_type',
      'key name' => 'Mapping ID',
      'identifier' => 'consumer_type',
      'primary key' => 'numeric_consumer_conf_id',
      'api' => array(
        'owner' => 'ldap_authorization',
        'api' => 'ldap_authorization',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'description' => "Data used to map users ldap entry to authorization rights.",
    'primary key' => array(
      'numeric_consumer_conf_id',
    ),
    'foreign keys' => array(
      'sid' => array(
        'table' => 'ldap_servers',
        'columns' => array(
          'sid' => 'sid',
        ),
      ),
    ),
  );
  module_load_include('inc', 'ldap_servers', 'ldap_servers.functions');
  ldap_server_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
  $fields = LdapAuthorizationConsumerConfAdmin::fields();
  foreach ($fields as $name => $props) {
    if (isset($props['schema'])) {
      $schema['ldap_authorization']['fields'][$name] = $props['schema'];
    }
  }
  return $schema;
}

/**
 * add 'create_consumers field to ldap_authorization table
 */
function ldap_authorization_update_7100() {
  if (!db_field_exists('ldap_authorization', 'create_consumers')) {
    db_add_field('ldap_authorization', 'create_consumers', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    return t('"create_consumers" field added to ldap_authorization table');
  }
  else {
    return t('No database changes made.');
  }
}

/**
 * add derive_from_attr_use_first_attr field to ldap_authorization table
 */
function ldap_authorization_update_7101() {
  if (!db_field_exists('ldap_authorization', 'derive_from_attr_use_first_attr')) {
    db_add_field('ldap_authorization', 'derive_from_attr_use_first_attr', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    return t('"derive_from_attr_use_first_attr" field added to ldap_authorization table');
  }
  else {
    return t('No database changes made.');
  }
}

/**
 * Add derive_from_entry_search_all column to ldap_authorization
 */
function ldap_authorization_update_7102() {
  if (!db_field_exists('ldap_authorization', 'derive_from_entry_search_all')) {
    db_add_field('ldap_authorization', 'derive_from_entry_search_all', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    return t('"derive_from_entry_search_all" field added to ldap_authorization table');
  }
  else {
    return t('No database changes made.');
  }
}

/**
 * change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
 */
function ldap_authorization_update_7103() {
  foreach (array(
    'derive_from_dn_attr',
    'derive_from_attr_attr',
    'derive_from_entry_entries',
  ) as $field_name) {
    db_change_field('ldap_authorization', $field_name, $field_name, array(
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
}

/**
 * change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
 * applied second time because beta6 and 7 were wrong.
 */
function ldap_authorization_update_7104() {
  foreach (array(
    'derive_from_dn_attr',
    'derive_from_attr_attr',
    'derive_from_entry_entries',
  ) as $field_name) {
    db_change_field('ldap_authorization', $field_name, $field_name, array(
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
}

/**
 * add derive_from_entry_user_ldap_attr field to allow user specification of dn or other identifier.
 */
function ldap_authorization_update_7105() {
  if (!db_field_exists('ldap_authorization', 'derive_from_entry_user_ldap_attr')) {
    db_add_field('ldap_authorization', 'derive_from_entry_user_ldap_attr', array(
      'type' => 'varchar',
      'length' => 255,
      'default' => NULL,
    ));
    return t('"derive_from_entry_user_ldap_attr" field added to ldap_authorization table');
  }
  else {
    return t('No database changes made.');
  }
}

/**
 * add nested checkboxes to derive from entry and attributes strategies.
 */
function ldap_authorization_update_7106() {
  if (!db_field_exists('ldap_authorization', 'derive_from_attr_nested')) {
    db_add_field('ldap_authorization', 'derive_from_attr_nested', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    $msg = t('"derive_from_attr_nested" field added to ldap_authorization table');
  }
  if (!db_field_exists('ldap_authorization', 'derive_from_entry_nested')) {
    db_add_field('ldap_authorization', 'derive_from_entry_nested', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    $msg .= t('"derive_from_entry_nested" field added to ldap_authorization table');
  }
  return $msg ? $msg : t('No database changes made.');
}

/**
 * add derive_from_entry_use_first_attr field to and remove description field from ldap_authorization table
 */
function ldap_authorization_update_7107() {
  $changes = '';
  if (!db_field_exists('ldap_authorization', 'derive_from_entry_use_first_attr')) {
    db_add_field('ldap_authorization', 'derive_from_entry_use_first_attr', array(
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    ));
    $changes .= t('"derive_from_entry_use_first_attr" field added to ldap_authorization table');
  }
  if (db_field_exists('ldap_authorization', 'description')) {
    db_drop_field('ldap_authorization', 'description');
    $changes .= t('"description" field dropped from to ldap_authorization table');
  }
  return $changes ? $changes : t('No database changes made.');
}

/**
 * add derive_from_entry_entries_attr field to allow user specification of attribute representing group in queries.
 */
function ldap_authorization_update_7108() {
  if (!db_field_exists('ldap_authorization', 'derive_from_entry_entries_attr')) {
    db_add_field('ldap_authorization', 'derive_from_entry_entries_attr', array(
      'type' => 'varchar',
      'length' => 255,
      'default' => NULL,
    ));
    return t('"derive_from_entry_entries_attr" field added to ldap_authorization table');
  }
  else {
    return t('No database changes made.');
  }
}

Functions

Namesort descending Description
ldap_authorization_requirements Implements hook_requirements().
ldap_authorization_schema Implements hook_schema().
ldap_authorization_update_7100 add 'create_consumers field to ldap_authorization table
ldap_authorization_update_7101 add derive_from_attr_use_first_attr field to ldap_authorization table
ldap_authorization_update_7102 Add derive_from_entry_search_all column to ldap_authorization
ldap_authorization_update_7103 change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
ldap_authorization_update_7104 change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555 applied second time because beta6 and 7 were wrong.
ldap_authorization_update_7105 add derive_from_entry_user_ldap_attr field to allow user specification of dn or other identifier.
ldap_authorization_update_7106 add nested checkboxes to derive from entry and attributes strategies.
ldap_authorization_update_7107 add derive_from_entry_use_first_attr field to and remove description field from ldap_authorization table
ldap_authorization_update_7108 add derive_from_entry_entries_attr field to allow user specification of attribute representing group in queries.