function domain_install in Domain Access 5
Same name and namespace in other branches
- 8 domain/domain.install \domain_install()
- 6.2 domain.install \domain_install()
- 7.3 domain.install \domain_install()
- 7.2 domain.install \domain_install()
Implement hook_install()
File
- ./
domain.install, line 11 - Install file.
Code
function domain_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query("CREATE TABLE {domain} (\n domain_id int(11) NOT NULL AUTO_INCREMENT,\n subdomain varchar(255) NOT NULL default '',\n sitename varchar(255) NOT NULL default '',\n scheme varchar(8) NOT NULL default 'http',\n valid varchar(1) NOT NULL default 1,\n PRIMARY KEY (domain_id),\n KEY subdomain (subdomain)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {domain_access} (\n nid int unsigned NOT NULL default '0',\n gid int unsigned NOT NULL default '0',\n realm varchar(255) NOT NULL default '',\n PRIMARY KEY (nid,gid,realm),\n INDEX (nid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {domain} (\n domain_id serial,\n subdomain varchar(255) NOT NULL default '',\n sitename varchar(255) NOT NULL default '',\n scheme varchar(8) NOT NULL default 'http',\n valid varchar(1) NOT NULL default 1,\n PRIMARY KEY (domain_id)\n )");
db_query("CREATE INDEX {domain}_subdomain_idx ON {domain} (subdomain)");
db_query("CREATE TABLE {domain_access} (\n nid int_unsigned NOT NULL default '0',\n gid int_unsigned NOT NULL default '0',\n realm varchar(255) NOT NULL default '',\n PRIMARY KEY (nid,gid,realm)\n )");
db_query("CREATE INDEX {domain_access}_nid_idx ON {domain_access} (nid)");
break;
}
// Create the 'all' realm for Domain Access.
db_query("INSERT INTO {node_access} VALUES (0, 0, 'domain_all', 1, 0, 0)");
// Set the primary domain.
$root = strtolower(rtrim($_SERVER['SERVER_NAME']));
$site = variable_get('site_name', 'Drupal');
$scheme = 'http';
if (!empty($_SERVER['HTTPS'])) {
$scheme = 'https';
}
// Set the default domain variables.
variable_set('domain_root', $root);
variable_set('domain_scheme', $scheme);
variable_set('domain_sitename', $site);
}