You are here

function ad_permission_install in Advertisement 5.2

Ad module permissions system database schema. Copyright (c) 2008 Jeremy Andrews <jeremy@tag1consulting.com>.

File

permission/ad_permission.install, line 8

Code

function ad_permission_install() {
  switch ($GLOBALS['db_type']) {
    case 'pgsql':

      /**
       * Every ad can have one or more owners.
       */
      db_query("CREATE TABLE {ad_owners} (\n       oid SERIAL NOT NULL PRIMARY KEY,\n       aid INT NOT NULL DEFAULT '0',\n       uid INT NOT NULL DEFAULT '0'\n     );");

      /**
       * Permissions can be granted to each owner of each ad.  The same owner
       * can own multiple ads, and can have different permissions for each ad.
       */
      db_query("CREATE TABLE {ad_permissions} (\n       oid INT NOT NULL DEFAULT '0' PRIMARY KEY,\n       permissions TEXT NULL DEFAULT ''\n     );");

      /**
       * The ad_hosts table is used to configure users that can display ads
       * remotely.
       */
      db_query("CREATE TABLE {ad_hosts} (\n        uid INT NOT NULL DEFAULT '0' PRIMARY KEY,\n \n        hostid varchar(32) DEFAULT '',\n        status INT NOT NULL DEFAULT '0',\n        description TEXT NOT NULL DEFAULT ''\n      );");
      break;
    case 'mysql':
    case 'mysqli':
    default:

      /**
       * Every ad can have one or more owners.
       */
      db_query("CREATE TABLE IF NOT EXISTS {ad_owners} (\n        oid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        aid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n        uid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\n        PRIMARY KEY  (oid),\n        KEY  (aid),\n        KEY  (uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      /**
       * Permissions can be granted to each owner of each ad.  The same owner
       * can own multiple ads, and can have different permissions for each ad.
       */
      db_query("CREATE TABLE IF NOT EXISTS {ad_permissions} (\n        oid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n        permissions LONGTEXT NULL,\n        PRIMARY KEY  (oid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      /**
       * The ad_hosts table is used to configure users that can display ads
       * remotely.
       */
      db_query("CREATE TABLE IF NOT EXISTS {ad_hosts} (\n        uid INT UNSIGNED NOT NULL DEFAULT '0',\n\n        hostid varchar(32) DEFAULT '',\n\n        status INT(2) UNSIGNED NOT NULL DEFAULT '0',\n        description TEXT NULL,\n\n        PRIMARY KEY  (uid),\n        KEY  (status),\n        KEY  (hostid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
  }
  drupal_set_message(t('The necessary ad module tables have been created.'));
}