You are here

function notifications_install in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications.install \notifications_install()
  2. 6 notifications.install \notifications_install()
  3. 6.2 notifications.install \notifications_install()
  4. 6.3 notifications.install \notifications_install()

Implementation of hook_install().

File

./notifications.install, line 5

Code

function notifications_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {notifications} (\n                `sid` int(10) unsigned NOT NULL auto_increment,\n                `uid` int(11) NOT NULL,\n                `type` varchar(255) default NULL,\n                `event_type` varchar(255) default NULL,\n                `conditions` int(10) unsigned NOT NULL,\n                `send_interval` int(11) default NULL,\n                `send_method` varchar(255) NOT NULL,\n                `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0,\n                `module` VARCHAR(255) DEFAULT NULL,\n                `status` int NOT NULL default 1,\n                PRIMARY KEY  (`sid`)\n              )/*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE  {notifications_fields} (\n                    `sid` int(10) unsigned NOT NULL,\n                    `field` varchar(255) NOT NULL,\n                    `value` varchar(255) NOT NULL,\n                    PRIMARY KEY  (`sid`,`field`)\n                  )/*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE  {notifications_queue} (\n                    `sqid` int(10) unsigned NOT NULL auto_increment,\n                    `eid` int(11) unsigned NOT NULL default '0',\n                    `sid` int(11) unsigned NOT NULL default '0',\n                    `uid` int(11) default NULL,\n                    `language` varchar(255) default NULL,\n                    `type` varchar(255) default NULL,\n                    `send_interval` int(11) default NULL,\n                    `send_method` varchar(255) default NULL,\n                    `sent` int(10) unsigned NOT NULL default '0',\n                    `created` int(10) unsigned NOT NULL default '0',\n                    `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0,\n                    `conditions` INTEGER UNSIGNED NOT NULL DEFAULT 0,\n                    `module` VARCHAR(255) DEFAULT NULL,\n                    PRIMARY KEY  (`sqid`)\n                  )/*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE  {notifications_event} (\n                    `eid` int(11) unsigned NOT NULL auto_increment,\n                    `module` varchar(255) default NULL,\n                    `type` varchar(255) default NULL,\n                    `action` varchar(255) default NULL,\n                    `oid` int(11) unsigned NOT NULL default '0',\n                    `language` varchar(255) default NULL,\n                    `uid` int(11) default NULL,\n                    `params` text,\n                    `created` int(11) unsigned NOT NULL default '0',\n                    PRIMARY KEY  (`eid`)\n                  )/*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE  {notifications_sent} (\n                    `uid` int(11) NOT NULL default '0',\n                    `send_interval` int(10) NOT NULL default '0',\n                    `send_method` varchar(50) NOT NULL,\n                    `sent` int(10) unsigned NOT NULL default '0',\n                    PRIMARY KEY  (`uid`,`send_interval`,`send_method`)\n                  )/*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {notifications} (\n                sid serial,\n                uid int NOT NULL,\n                type varchar(255) DEFAULT NULL,\n                event_type varchar(255) DEFAULT NULL,\n                conditions int NOT NULL,\n                send_interval int DEFAULT NULL,\n                send_method varchar(255) NOT NULL,\n                cron smallint NOT NULL DEFAULT 0,\n                module varchar(255) DEFAULT NULL,\n                status smallint NOT NULL DEFAULT 1,\n                PRIMARY KEY (sid)\n              )");
      db_query("CREATE TABLE  {notifications_fields} (\n                    sid int NOT NULL,\n                    field varchar(255) NOT NULL,\n                    value varchar(255) NOT NULL,\n                    PRIMARY KEY (sid,field)\n                  )");
      db_query("CREATE TABLE  {notifications_queue} (\n                    sqid serial,\n                    eid int NOT NULL DEFAULT '0',\n                    sid int NOT NULL DEFAULT '0',\n                    uid int DEFAULT NULL,\n                    language varchar(255) DEFAULT NULL,\n                    type varchar(255) DEFAULT NULL,\n                    send_interval int DEFAULT NULL,\n                    send_method varchar(255) DEFAULT NULL,\n                    sent int NOT NULL DEFAULT '0',\n                    created int NOT NULL DEFAULT '0',\n                    cron smallint NOT NULL DEFAULT 0,\n                    conditions smallint NOT NULL DEFAULT 0,\n                    module varchar(255) DEFAULT NULL,\n                    PRIMARY KEY (sqid)\n                  )");
      db_query("CREATE TABLE  {notifications_event} (\n                    eid serial,\n                    module varchar(255) DEFAULT NULL,\n                    type varchar(255) DEFAULT NULL,\n                    action varchar(255) DEFAULT NULL,\n                    oid int NOT NULL DEFAULT '0',\n                    language varchar(255) DEFAULT NULL,\n                    uid int DEFAULT NULL,\n                    params text,\n                    created int NOT NULL DEFAULT '0',\n                    PRIMARY KEY (eid)\n                  )");
      db_query("CREATE TABLE  {notifications_sent} (\n                    uid int NOT NULL DEFAULT '0', \n                    send_interval int NOT NULL DEFAULT '0',\n                    send_method varchar(50) NOT NULL,\n                    sent int NOT NULL DEFAULT '0',\n                    PRIMARY KEY (uid,send_interval,send_method)\n                  )");
      break;
  }

  // Module weight. It must run after most modules, to make sure they've done their work before we add the notifications queries
  db_query("UPDATE {system} SET weight = 100 WHERE name = 'notifications_content' AND type = 'module'");
}