function domain_update_2 in Domain Access 5
Updates from rc2 to rc3. Adds the {domain_access} table and copies data from {node_access} to {domain_access}.
Required to prevent deletions during node_access_rebuild(). See http://groups.drupal.org/node/7956
File
- ./
domain.install, line 101 - Install file.
Code
function domain_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("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':
$ret[] = update_sql("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 )");
$ret[] = update_sql("CREATE INDEX {domain_access}_nid_idx ON {domain_access} (nid)");
break;
}
$realms = array(
'domain_site',
'domain_id',
'domain_editor',
);
foreach ($realms as $realm) {
$result = db_query("SELECT * FROM {node_access} WHERE realm = '%s'", $realm);
while ($data = db_fetch_array($result)) {
db_query("INSERT INTO {domain_access} VALUES (%d, %d, '%s')", $data['nid'], $data['gid'], $data['realm']);
}
}
return $ret;
}