You are here

function simplenews_install in Simplenews 5

Same name and namespace in other branches
  1. 8.2 simplenews.install \simplenews_install()
  2. 8 simplenews.install \simplenews_install()
  3. 6.2 simplenews.install \simplenews_install()
  4. 6 simplenews.install \simplenews_install()
  5. 7.2 simplenews.install \simplenews_install()
  6. 7 simplenews.install \simplenews_install()
  7. 3.x simplenews.install \simplenews_install()

File

./simplenews.install, line 3

Code

function simplenews_install() {
  $result = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $result[] = db_query("CREATE TABLE {simplenews_subscriptions} (\n        snid int(10) NOT NULL auto_increment,\n        a_status int(2) NOT NULL default '0',\n        s_status int(2) NOT NULL default '0',\n        mail varchar(64) NOT NULL default '',\n        uid int(10) NOT NULL default '0',\n        PRIMARY KEY  (snid),\n        KEY mail (mail)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $result[] = db_query("CREATE TABLE {simplenews_newsletters} (\n        nid int(10) NOT NULL default '0',\n        vid int(10) NOT NULL default '0',\n        tid int(10) NOT NULL default '0',\n        s_status int(2) NOT NULL default '0',\n        s_format varchar(8) NOT NULL default '',\n        priority int(2) NOT NULL default '0',\n        receipt int(2) NOT NULL default '0',\n        PRIMARY KEY  (nid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $result[] = db_query("CREATE TABLE {simplenews_snid_tid} (\n        snid int(10) NOT NULL default '0',\n        tid int(10) NOT NULL default '0',\n        PRIMARY KEY  (snid,tid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $result[] = db_query("CREATE TABLE {simplenews_subscriptions} (\n        snid SERIAL,\n        a_status smallint NOT NULL default '0',\n        s_status smallint NOT NULL default '0',\n        mail varchar(64) NOT NULL default '',\n        uid integer NOT NULL default '0',\n        PRIMARY KEY  (snid)\n        );");
      $result[] = db_query('CREATE INDEX {simplenews_subscriptions}_mail_idx ON {simplenews_subscriptions} (mail)');
      $result[] = db_query("CREATE TABLE {simplenews_newsletters} (\n        nid integer NOT NULL default '0',\n        vid integer NOT NULL default '0',\n        tid integer NOT NULL default '0',\n        s_status smallint NOT NULL default '0',\n        s_format varchar(8) NOT NULL default '',\n        priority smallint NOT NULL default '0',\n        receipt smallint NOT NULL default '0',\n        PRIMARY KEY  (nid)\n        );");
      $result[] = db_query("CREATE TABLE {simplenews_snid_tid} (\n        snid integer NOT NULL default '0',\n        tid integer NOT NULL default '0',\n        PRIMARY KEY  (snid,tid)\n        );");
      break;
    case 'mssql':
      $result[] = db_query("CREATE TABLE {simplenews_subscriptions} (\n        snid int NOT NULL IDENTITY(1,1),\n        a_status int NOT NULL default '0',\n        s_status int NOT NULL default '0',\n        mail varchar(64) NOT NULL default '',\n        uid int NOT NULL default '0',\n        PRIMARY KEY (snid)\n        );");
      $result[] = db_query("CREATE TABLE {simplenews_newsletters} (\n        nid int NOT NULL default '0',\n        tid int NOT NULL default '0',\n        s_status int NOT NULL default '0',\n        s_format varchar(8) NOT NULL default '',\n        priority int NOT NULL default '0',\n        receipt int NOT NULL default '0',\n        PRIMARY KEY (nid)\n        );");
      $result[] = db_query("CREATE TABLE {simplenews_snid_tid} (\n        snid int NOT NULL default '0',\n        tid int NOT NULL default '0',\n        PRIMARY KEY  (snid,tid)\n        );");
      break;
  }
  if (count($result) != count(array_filter($result))) {
    drupal_set_message(t('The installation of the Simplenews module was unsuccessful.'), 'error');
  }
}