You are here

function simple_access_install in Simple Access 5

Same name and namespace in other branches
  1. 8.3 simple_access.install \simple_access_install()
  2. 5.2 simple_access.install \simple_access_install()
  3. 6.2 simple_access.install \simple_access_install()
  4. 7.2 simple_access.install \simple_access_install()

Implementation of hook_install()

File

./simple_access.install, line 6

Code

function simple_access_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {simple_access_node} (\n        nid int(10) unsigned NOT NULL default '0',\n        gid int(10) unsigned NOT NULL default '0',\n        `view` tinyint unsigned NOT NULL default '0',\n        `update` tinyint unsigned NOT NULL default '0',\n        `delete` tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY  (nid, gid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {simple_access_groups} (\n        gid int(10) NOT NULL default '0',\n        name varchar(50) NOT NULL default '',\n        weight int(3) NOT NULL default '0'\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {simple_access_roles} (\n        gid int(10) NOT NULL default '0',\n        rid int(10) NOT NULL default '0'\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {simple_access_groups} (\n        nid integer unsigned NOT NULL default '0',\n        gid integer unsigned NOT NULL default '0',\n        view integer unsigned NOT NULL default '0',\n        update integer unsigned NOT NULL default '0',\n        delete integer unsigned NOT NULL default '0',\n      );");
      db_query("CREATE TABLE {simple_access_groups} (\n        gid serial NOT NULL,\n        name varchar(50) NOT NULL default '',\n        weight integer NOT NULL default '0'\n      );");
      db_query("CREATE TABLE {simple_access_roles} (\n        gid integer NOT NULL default '0',\n        rid integer NOT NULL default '0'\n      );");
      break;
  }
  drupal_set_message(t('simple access has created the required tables.'));
}