You are here

path_access.install in Path Access 5

Same filename and directory in other branches
  1. 6 path_access.install
  2. 7 path_access.install

File

path_access.install
View source
<?php

function path_access_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE IF NOT EXISTS {path_access} (\n                  `pid` int(10) NOT NULL default '0',\n                  `rid` int(10) NOT NULL default '0',\n                  `pages` text,\n                  `visibility` tinyint(1) NOT NULL default '0',\n                  PRIMARY KEY  (`pid`),\n                  KEY `rid` (`rid`)\n                  );");

      // By default grant access to all anon and authenticated users
      db_query("INSERT INTO {path_access} (pid, rid, pages, visibility) VALUES (%d, 1, '', 0)", db_next_id('path_access'));
      db_query("INSERT INTO {path_access} (pid, rid, pages, visibility) VALUES (%d, 2, '', 0)", db_next_id('path_access'));
      $success = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE SEQUENCE {path_access_seq}; \n           CREATE TABLE {path_access} (\n             pid integer not null default nextval('path_access_seq'),\n             rid integer not null default 0,\n             pages text,\n             visibility smallint not null default 0,\n             PRIMARY KEY(pid) \n           );\n         ");
      db_query("INSERT INTO {path_access} (rid, pages, visibility) VALUES (1, '', 0)");
      db_query("INSERT INTO {path_access} (rid, pages, visibility) VALUES (2, '', 0)");
      $success = TRUE;
      break;
  }
  if ($success) {
    drupal_set_message(t('Path Access module installed tables successfully.'));
  }
  else {
    drupal_set_message(t('The installation of Path Access module was unsuccessful.'), 'error');
  }
}
function path_access_uninstall() {
  db_query('DROP TABLE {path_access}');
  db_query('DROP SEQUENCE {path_access_seq}');
}