You are here

borealis_sb.install in Borealis 7

Same filename and directory in other branches
  1. 7.2 borealis_sb/borealis_sb.install

File

borealis_sb/borealis_sb.install
View source
<?php

/**
 * Install, update, and uninstall functions for Borealis SB module.
 */

/**
 * Implements hook_schema().
 */
function borealis_sb_schema() {
  $schema['borealis_sb'] = array(
    'description' => 'Stores Semantic settings for blocks.',
    'fields' => array(
      'uid' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => "Generated UID for module_delta combo.",
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
      ),
      'delta' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '0',
        'description' => 'Unique ID for block within a module.',
      ),
      'semantics' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The semantic wrapper to apply.',
      ),
    ),
    'primary key' => array(
      'uid',
    ),
    'export' => array(
      'key' => 'uid',
      'identifier' => 'semantic_wrapper',
      // Exports will be available as $tag
      'default hook' => 'default_semantic_wrapper',
      // Function hook name.
      'api' => array(
        'owner' => 'borealis_sb',
        'api' => 'borealis_sb_default',
        // Base name for api include files.
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install
 */
function borealis_sb_install() {
  drupal_install_schema('boralis_sb');
  borealis_sb_update_7100();
  borealis_sb_update_7101();
  borealis_sb_update_7102();
}

/**
 * Implements hook_
 */
function borealis_sb_uninstall() {
  drupal_uninstall_schema('borealis_sb');
}

/**
 * Ensures that Borealis SB is called absolutely last
 */
function borealis_sb_update_7100() {
  db_update('system')
    ->fields(array(
    'weight' => 99999,
  ))
    ->condition('name', 'borealis_sb')
    ->execute();
}

/**
 * Remove BID from Schema
 */
function borealis_sb_update_7101() {

  // db_drop_primary_key('borealis_sb');
  db_drop_field('borealis_sb', 'bid');
}

/**
 * Implements hook_uid
 */
function borealis_sb_update_7102() {
  if (!db_field_exists('borealis_sb', 'uid')) {
    $schema = array(
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
      'default' => '',
      'description' => "Generated UID for module_delta combo",
    );
    db_add_field('borealis_sb', 'uid', $schema);
  }
  $block_query = db_select('borealis_sb', 'b')
    ->fields('b');
  $block_result = $block_query
    ->execute();
  foreach ($block_result as $block) {
    $uid = $block->module . '_' . $block->delta;
    db_update('borealis_sb')
      ->fields(array(
      'uid' => $uid,
    ))
      ->condition('module', $block->module)
      ->condition('delta', $block->delta)
      ->execute();
  }
}

Functions

Namesort descending Description
borealis_sb_install Implements hook_install
borealis_sb_schema Implements hook_schema().
borealis_sb_uninstall Implements hook_
borealis_sb_update_7100 Ensures that Borealis SB is called absolutely last
borealis_sb_update_7101 Remove BID from Schema
borealis_sb_update_7102 Implements hook_uid