You are here

function simple_access_install in Simple Access 5.2

Same name and namespace in other branches
  1. 8.3 simple_access.install \simple_access_install()
  2. 5 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 11
Simple Access Installation file

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        `sa_view` tinyint unsigned NOT NULL default '0',\n        `sa_update` tinyint unsigned NOT NULL default '0',\n        `sa_delete` tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY  (nid, gid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {simple_access_owner} (\n        nid int(10) unsigned NOT NULL default '0',\n        `sa_view` tinyint unsigned NOT NULL default '0',\n        `sa_update` tinyint unsigned NOT NULL default '0',\n        `sa_delete` tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY  (nid)\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 */;");
      db_query("CREATE TABLE {simple_access_profiles} (\n        pid int(10) NOT NULL default '0',\n        name varchar(50) NOT NULL default '',\n        weight int(3) NOT NULL default '0',\n        PRIMARY KEY  (`pid`)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {simple_access_profiles_access} (\n        pid int(10) unsigned NOT NULL default '0',\n        gid int(10) unsigned NOT NULL default '0',\n        sa_view tinyint(3) unsigned NOT NULL default '0',\n        sa_update tinyint(3) unsigned NOT NULL default '0',\n        sa_delete tinyint(3) unsigned NOT NULL default '0',\n        PRIMARY KEY  (pid,gid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {simple_access_profiles_node} (\n        nid int(10) NOT NULL,\n        pid int(10) NOT NULL,\n        PRIMARY KEY  (nid,pid)\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        sa_view integer unsigned NOT NULL default '0',\n        sa_update integer unsigned NOT NULL default '0',\n        sa_delete integer unsigned NOT NULL default '0',\n      );");
      db_query("CREATE TABLE {simple_access_owner} (\n        nid integer unsigned NOT NULL default '0',\n        sa_view integer unsigned NOT NULL default '0',\n        sa_update integer unsigned NOT NULL default '0',\n        sa_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      );");
      db_query("CREATE TABLE {simple_access_profiles} (\n        pid int(10) NOT NULL default '0',\n        name varchar(50) NOT NULL default '',\n        weight int(3) NOT NULL default '0'\n      );");
      db_query("CREATE TABLE {simple_access_profiles_access} (\n        pid int(10) unsigned NOT NULL default '0',\n        gid int(10) unsigned NOT NULL default '0',\n        sa_view int(3) unsigned NOT NULL default '0',\n        sa_update int(3) unsigned NOT NULL default '0',\n        sa_delete int(3) unsigned NOT NULL default '0'\n      );");
      db_query("CREATE TABLE {simple_access_profiles_node} (\n        nid int(10) NOT NULL,\n        pid int(10) NOT NULL\n      );");
      break;
  }
  drupal_set_message(t('simple access has created the required tables.'));
}