You are here

block_aria_landmark_roles.install in Block ARIA Landmark Roles 7.2

Install, update, and uninstall functions for the Blocks ARIA Landmark Roles module.

File

block_aria_landmark_roles.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Blocks ARIA Landmark Roles module.
 */

/**
 * Remove the primary key from the table.
 */
function block_aria_landmark_roles_update_7100() {
  db_drop_primary_key('block_aria_landmark_roles');
}

/**
 * Rename the 'aria_role' column to 'role'.
 */
function block_aria_landmark_roles_update_7101() {
  $spec = array(
    'description' => 'The assigned landmark role',
    'type' => 'varchar',
    'length' => '255',
    'not null' => TRUE,
    'default' => '',
  );
  db_change_field('block_aria_landmark_roles', 'aria_role', 'role', $spec);
}

/**
 * Add a new table for ARIA labels.
 */
function block_aria_landmark_roles_update_7102() {
  $schema = array(
    'description' => 'Stores ARIA labels assigned to blocks',
    'fields' => array(
      'module' => array(
        'description' => 'The name of the module that generates the block',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'delta' => array(
        'description' => 'The delta value of the block',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'description' => 'The assigned label',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
    ),
  );
  db_create_table('block_aria_landmark_roles_label', $schema);
}

/**
 * Move roles to use variables instead of a custom table.
 */
function block_aria_landmark_roles_update_7200() {
  $query = db_query('SELECT * FROM {block_aria_landmark_roles}');
  $query
    ->execute();
  foreach ($query
    ->fetchAll() as $row) {
    $key = "block_aria_landmark_roles__{$row->module}__{$row->delta}";
    variable_set($key, $row->role);
  }
}

/**
 * Move labels to use variables instead of a custom table.
 */
function block_aria_landmark_roles_update_7201() {
  $query = db_query('SELECT * FROM {block_aria_landmark_roles_label}');
  $query
    ->execute();
  foreach ($query
    ->fetchAll() as $row) {
    $key = "block_aria_landmark_roles_label__{$row->module}__{$row->delta}";
    variable_set($key, $row->label);
  }
}

/**
 * Delete old tables.
 */
function block_aria_landmark_roles_update_7202() {
  foreach (array(
    'block_aria_landmark_roles',
    'block_aria_landmark_roles_label',
  ) as $table) {
    if (db_table_exists($table)) {
      db_drop_table($table);
    }
  }
}

Functions

Namesort descending Description
block_aria_landmark_roles_update_7100 Remove the primary key from the table.
block_aria_landmark_roles_update_7101 Rename the 'aria_role' column to 'role'.
block_aria_landmark_roles_update_7102 Add a new table for ARIA labels.
block_aria_landmark_roles_update_7200 Move roles to use variables instead of a custom table.
block_aria_landmark_roles_update_7201 Move labels to use variables instead of a custom table.
block_aria_landmark_roles_update_7202 Delete old tables.