You are here

function og_install in Organic groups 5.7

Same name and namespace in other branches
  1. 5.8 og.install \og_install()
  2. 5 og.install \og_install()
  3. 5.2 og.install \og_install()
  4. 5.3 og.install \og_install()
  5. 6.2 og.install \og_install()
  6. 6 og.install \og_install()
  7. 7.2 og.install \og_install()
  8. 7 og.install \og_install()

File

./og.install, line 3

Code

function og_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {og} (\n        nid int(11) NOT NULL,\n        selective int(11) NOT NULL default '0',\n        description varchar(255) NULL,\n        theme varchar(255) NULL,\n        register int(1) NOT NULL default 0,\n        directory int(1) NOT NULL default 0,\n        notification int(1) NOT NULL default 0,\n        language varchar(12) NOT NULL default '',\n        private int(1) NOT NULL default 0,\n        PRIMARY KEY  (nid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {og_uid} (\n        nid int(11) NOT NULL,\n        og_role int(1) NOT NULL DEFAULT 0,\n        is_active int(1) NOT NULL DEFAULT 0,\n        is_admin int(1) NOT NULL DEFAULT 0,\n        uid int(11) NOT NULL,\n        mail_type int(11) NULL,\n      \tcreated int(11) NULL DEFAULT 0,\n      \tchanged int(11) NULL DEFAULT 0,\n        PRIMARY KEY  (nid, uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {og_uid_global} (\n        uid int(11) NOT NULL,\n        og_email int(11) NOT NULL DEFAULT 2,\n        PRIMARY KEY  (uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {og_ancestry} (\n        nid int(11) NOT NULL,\n        group_nid int(11) NOT NULL,\n        is_public int(1) NOT NULL,\n        KEY  (nid),\n        KEY  (group_nid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {og} (\n        nid int NOT NULL,\n        selective int NOT NULL default 0,\n        description varchar(255) NULL,\n        theme varchar(255) NULL,\n        website varchar(255) NULL,\n        register smallint NOT NULL default 0,\n        directory smallint NOT NULL default 0,\n        notification smallint NOT NULL default 0,\n        language varchar(12) NOT NULL default '',\n        private smallint NOT NULL default 0,  \n        PRIMARY KEY  (nid)\n      );");
      db_query("CREATE TABLE {og_uid} (\n        nid int NOT NULL,\n        og_role smallint NOT NULL DEFAULT 0,\n        is_active smallint NOT NULL DEFAULT 0,\n        is_admin smallint NOT NULL DEFAULT 0,\n        uid int NOT NULL,\n        mail_type int NULL,\n\t    created int NULL DEFAULT 0,\n\t    changed int NULL DEFAULT 0,\n        PRIMARY KEY  (nid, uid)\n      );");
      db_query("CREATE TABLE {og_uid_global} (\n        uid int NOT NULL,\n        og_email int NOT NULL DEFAULT 2,\n        PRIMARY KEY (uid)\n      );");
      db_query("\n      CREATE TABLE {og_ancestry} (\n       nid int NOT NULL,\n       group_nid int NOT NULL,\n       is_public smallint NOT NULL\n      );");
      db_query("CREATE INDEX {og_ancestry}_nid_idx ON {og_ancestry} (nid);");
      db_query("CREATE INDEX {og_ancestry}_group_nid_idx ON {og_ancestry} (group_nid);");
      break;
  }

  // enable standard og blocks. for custom profiles, block may not be included yet.
  if (function_exists('block_rehash')) {
    _block_rehash();
  }

  // Need og_readme() function.
  drupal_load('module', 'og');
  drupal_set_message(t('Organic groups module enabled. Please see the included !README file for further installation instructions.', array(
    '!README' => og_readme(),
  )));
}