You are here

block_access.install in Block Access 6.2

Same filename and directory in other branches
  1. 6 block_access.install
  2. 7 block_access.install

block_access module installation and upgrade code.

File

block_access.install
View source
<?php

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

/**
 * Implementation of hook_schema().
 */
function block_access_schema() {
  $schema['block_access_roles'] = array(
    'description' => 'Extension of blocks_roles',
    'fields' => array(
      'module' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => "The block's origin module, from {blocks}.module.",
      ),
      'delta' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
        'description' => "The block's unique delta within module, from {blocks}.delta.",
      ),
      'rid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => "The user's role ID from {users_roles}.rid.",
      ),
      'permission' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'The permission being granted',
      ),
    ),
    'primary key' => array(
      'module',
      'delta',
      'rid',
      'permission',
    ),
    'indexes' => array(
      'rid' => array(
        'rid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function block_access_install() {
  drupal_install_schema('block_access');
}

/**
 * Implementation of hook_uninstall().
 */
function block_access_uninstall() {
  drupal_uninstall_schema('block_access');
}
function block_access_update_6001() {
  $ret = array();
  drupal_install_schema('block_access');
  $ret[] = update_sql("INSERT INTO {block_access_roles} SELECT * FROM {blocks_roles} WHERE permission != ''");
  $ret[] = update_sql("DELETE FROM {blocks_roles} WHERE permission != ''");
  db_drop_primary_key($ret, 'blocks_roles');
  db_drop_field($ret, 'blocks_roles', 'permission');
  db_add_primary_key($ret, 'blocks_roles', array(
    'module',
    'delta',
    'rid',
  ));
  return $ret;
}
function block_access_update_6002() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {block_access_roles} MODIFY delta varchar(32) NULL");
  return $ret;
}