You are here

ack_menu.install in Access Control Kit 7

Install, update, and uninstall functions for the ACK menu module.

File

ack_menu/ack_menu.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the ACK menu module.
 */

/**
 * Implements hook_schema().
 */
function ack_menu_schema() {
  $schema['ack_menu_map'] = array(
    'description' => 'Maps menu trees to access realms.',
    'fields' => array(
      'mlid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {menu_links}.mlid that identifies the top link of the realm menu tree.',
      ),
      'scheme' => array(
        'type' => 'varchar',
        'length' => 28,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The {access_scheme}.machine_name of the scheme that contains the realm.',
      ),
      'realm' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The realm value.',
      ),
    ),
    'primary key' => array(
      'mlid',
      'scheme',
    ),
    'indexes' => array(
      'realm' => array(
        array(
          'scheme',
          4,
        ),
        'realm',
      ),
    ),
    'foreign keys' => array(
      'menu_link' => array(
        'table' => 'menu_links',
        'columns' => array(
          'mlid' => 'mlid',
        ),
      ),
      'scheme_machine_name' => array(
        'table' => 'access_scheme',
        'columns' => array(
          'scheme' => 'machine_name',
        ),
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function ack_menu_install() {

  // Make sure that this module's hooks execute after the menu module's.
  $weight = db_query('SELECT weight FROM {system} WHERE name = :name', array(
    ':name' => 'menu',
  ))
    ->fetchField();
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('name', 'ack_menu')
    ->execute();
}

/**
 * Fix module weight relative to the menu module.
 */
function ack_menu_update_7100() {

  // Make sure that this module's hooks execute after the menu module's.
  $weight = db_query('SELECT weight FROM {system} WHERE name = :name', array(
    ':name' => 'menu',
  ))
    ->fetchField();
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('name', 'ack_menu')
    ->execute();
}

Functions

Namesort descending Description
ack_menu_install Implements hook_install().
ack_menu_schema Implements hook_schema().
ack_menu_update_7100 Fix module weight relative to the menu module.