You are here

ad_channel.install in Advertisement 5.2

File

channel/ad_channel.install
View source
<?php

/**
 *
 * Ad channel database schema.
 * Copyright (c) 2008 Jeremy Andrews <jeremy@tag1consulting.com>.
 */

/**
 * Create the ad_channel schema.
 */
function ad_channel_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    default:

      // TODO: PostgreSQL support.  Patches welcome.

      /* The ad_channel table stores channel definitions and rules.
       */
      db_query("CREATE TABLE {ad_channel} (\n        chid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        name VARCHAR(64) NOT NULL DEFAULT '',\n        description LONGTEXT NULL,\n        conid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n        weight TINYINT(4) SIGNED NOT NULL DEFAULT '0',\n        display TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n        urls TEXT NULL,\n        groups TEXT NULL,\n        PRIMARY KEY  (chid),\n        KEY  (name)\n      );");

      /* The ad_channel_container table stores channel container definitions.
       */
      db_query("CREATE TABLE {ad_channel_container} (\n        conid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        name VARCHAR(64) NOT NULL DEFAULT '',\n        description LONGTEXT NULL,\n        weight TINYINT(4) SIGNED NOT NULL DEFAULT '0',\n        PRIMARY KEY  (conid)\n      );");

      /* The ad_channel_node table stores per node channel information.
       */
      db_query("CREATE TABLE {ad_channel_node} (\n        chid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n        nid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n        PRIMARY KEY  (chid, nid),\n        KEY (nid, chid)\n      );");

      /* The ad_channel_node table stores per node channel information.
       */
      db_query("CREATE TABLE {ad_priority} (\n        aid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n        priority TINYINT UNSIGNED NOT NULL DEFAULT '0',\n        PRIMARY KEY  (aid, priority)\n      );");
  }
}

/**
 * Completely uninstall the ad channel module.
 */
function ad_channel_uninstall() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    default:

      // TODO: PostgreSQL support.  Patches welcome.
      db_query('DROP TABLE {ad_channel}');
      db_query('DROP TABLE {ad_channel_container}');
      db_query('DROP TABLE {ad_channel_node}');
  }
}

Functions

Namesort descending Description
ad_channel_install Create the ad_channel schema.
ad_channel_uninstall Completely uninstall the ad channel module.