You are here

shoutbox.install in Shoutbox 6

Shoutbox module install file.

File

shoutbox.install
View source
<?php

/**
 * @file
 * Shoutbox module install file.
 */

/**
 * Define the 'shoutbox' and 'shoutbox_moderation' table structures.
 *
 * @return
 *   The schema which contains the structure for the shoutbox module's tables.
 */
function shoutbox_schema() {
  $schema['shoutbox'] = array(
    'description' => t('A table containing the shoutbox posts.'),
    'fields' => array(
      'shout_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t('The primary identifier for the shout post.'),
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The primary identifier for the shout post author.'),
      ),
      'nick' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => t('The author\'s nickname.'),
      ),
      'shout' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => t('The shout post.'),
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'description' => t('The url of the post.'),
      ),
      'moderate' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The moderation id.'),
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Creation date.'),
      ),
      'changed' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Last updated date.'),
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => t('The hostname where the post originated.'),
      ),
      'sid' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Session id of the current session.'),
      ),
    ),
    'primary key' => array(
      'shout_id',
    ),
  );
  return $schema;
}
function shoutbox_install() {
  drupal_install_schema('shoutbox');
}

/**
 * Uninstall shoutbox.
 */
function shoutbox_uninstall() {
  drupal_uninstall_schema('shoutbox');

  // Delete variables.
  variable_del('shoutbox_expire');
  variable_del('shoutbox_showamount');
  variable_del('shoutbox_ascending');
  variable_del('shoutbox_defaultname');
  variable_del('shoutbox_shownamefield');
  variable_del('shoutbox_showurlfield');
  variable_del('shoutbox_refresh');
  variable_del('shoutbox_anonymous_timeout');
  variable_del('shoutbox_registered_timeout');
  variable_del('shoutbox_filter_format');
}

/**
 * Update hook.
 * This update prepares the database for for
 * shoutbox 5.2.x
 * Removes the moderation table
 * Drops the status column on the shoutbox table
 * Adds sid column to the shoutbox table
 *
 */
function shoutbox_update_5200() {
  $items = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    case 'pgsql':
      $items[] = update_sql("DROP TABLE {shoutbox_moderation}");
      $items[] = update_sql("ALTER TABLE {shoutbox} DROP status");
      $items[] = update_sql("ALTER TABLE {shoutbox} ADD COLUMN sid varchar(64) NOT NULL default ''");
      break;
    default:
      break;
  }
  return $items;
}

Functions

Namesort descending Description
shoutbox_install
shoutbox_schema Define the 'shoutbox' and 'shoutbox_moderation' table structures.
shoutbox_uninstall Uninstall shoutbox.
shoutbox_update_5200 Update hook. This update prepares the database for for shoutbox 5.2.x Removes the moderation table Drops the status column on the shoutbox table Adds sid column to the shoutbox table