You are here

shoutbox.install in Shoutbox 5

File

shoutbox.install
View source
<?php

function shoutbox_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {shoutbox} ( shout_id int(10) unsigned NOT NULL auto_increment, uid int(10) NOT NULL default '0', nick varchar(32) NOT NULL default '', shout varchar(255) NOT NULL default '', url varchar(100) NOT NULL default '', moderate int(2) NOT NULL default '0', created int(11) NOT NULL default '0', changed int(11) NOT NULL default '0', hostname varchar(255) NOT NULL default '', sid varchar(64) NOT NULL default '', PRIMARY KEY  (shout_id)) /*!40100 DEFAULT CHARACTER SET utf8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {shoutbox} ( shout_id serial NOT NULL, uid int NOT NULL default '0', nick varchar(32) NOT NULL default '', shout varchar(255) NOT NULL default '', url varchar(100) NOT NULL default '', moderate int NOT NULL default '0', created int NOT NULL default '0', changed int NOT NULL default '0', hostname varchar(255) NOT NULL default '', sid varchar(64) NOT NULL default '', PRIMARY KEY (shout_id))");
      break;
  }
}

/**
 * Uninstall shoutbox.
 */
function shoutbox_uninstall() {
  switch ($GLOBALS['db_type']) {
    case 'pgsql':
    case 'mysql':
    case 'mysqli':
    default:
      db_query("DROP TABLE {shoutbox}");
      break;
  }

  // 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_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