You are here

twitter_block.install in Twitter Block 7.2

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

Install, update and uninstall functions for the twitter_block module.

File

twitter_block.install
View source
<?php

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

/**
 * Implements hook_schema().
 */
function twitter_block_schema() {
  $schema['twitter_block'] = array(
    'description' => 'The table for storing twitter blocks.',
    'fields' => array(
      'bid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => "The block's {block}.bid.",
      ),
      'info' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Block description.',
      ),
      'widget_id' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Widget ID.',
      ),
      'username' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Account username.',
      ),
      'data' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
        'description' => 'Serialized data containing the timeline properties.',
      ),
    ),
    'unique keys' => array(
      'info' => array(
        'info',
      ),
      'widget_id' => array(
        'widget_id',
      ),
    ),
    'primary key' => array(
      'bid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function twitter_block_uninstall() {

  // Remove blocks.
  db_delete('block')
    ->condition('module', 'twitter_block')
    ->execute();
  db_delete('block_role')
    ->condition('module', 'twitter_block')
    ->execute();

  // Remove variables.
  variable_del('twitter_block_cache');
  variable_del('twitter_block_last_cache');
}

/**
 * Implements hook_disable().
 *
 * Remove cache directory if module is disabled (or uninstalled).
 */
function twitter_block_disable() {
  twitter_block_clear_js_cache();
}

/**
 * Remove any old Twitter Block blocks and install the new Twitter Block schema.
 */
function twitter_block_update_7200() {

  // Remove old Twitter Block schema.
  drupal_uninstall_schema('twitter_block');

  // Remove any old Twitter Block blocks.
  db_delete('block')
    ->condition('module', 'twitter_block')
    ->execute();
  db_delete('block_role')
    ->condition('module', 'twitter_block')
    ->execute();

  // Clear the site cache.
  cache_clear_all();

  // Install the new Twitter Block schema.
  drupal_install_schema('twitter_block');
  return t('Removed any old Twitter Block blocks and installed the new Twitter Block schema.');
}

/**
 * Add a column to the {twitter_block} table to store the Twitter account username.
 */
function twitter_block_update_7201() {
  db_add_field('twitter_block', 'username', array(
    'type' => 'varchar',
    'length' => 128,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Account username.',
  ));
}

Functions

Namesort descending Description
twitter_block_disable Implements hook_disable().
twitter_block_schema Implements hook_schema().
twitter_block_uninstall Implements hook_uninstall().
twitter_block_update_7200 Remove any old Twitter Block blocks and install the new Twitter Block schema.
twitter_block_update_7201 Add a column to the {twitter_block} table to store the Twitter account username.