function domain_enable in Domain Access 5
Same name and namespace in other branches
- 6.2 domain.module \domain_enable()
- 7.3 domain.module \domain_enable()
- 7.2 domain.module \domain_enable()
Upon enabling this module, store the default view grant in the {node_access} table.
See also
File
- ./
domain.module, line 955 - Core module functions for the Domain Access suite.
Code
function domain_enable() {
domain_enabling(TRUE);
// Thanks to the new way that batch processing of node grants is handled, we have to
// manually define our records if none are present.
$count = db_result(db_query("SELECT COUNT(*) FROM {domain_access}"));
if ($count == 0) {
$rule = variable_get('domain_behavior', DOMAIN_INSTALL_RULE);
$edit = variable_get('domain_editors', DOMAIN_EDITOR_RULE);
$site = DOMAIN_SITE_GRANT;
$nids = db_query("SELECT nid FROM {node}");
while ($nid = db_fetch_object($nids)) {
if (!empty($site)) {
db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid->nid, 0, 'domain_site');
}
if (!empty($rule)) {
// By design, all nodes are assigned to the master domain.
db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid->nid, 0, 'domain_id');
// Editor rules only apply is nodes are assigned to a domain.
if (!empty($edit)) {
variable_set('domain_editors', TRUE);
db_query("INSERT INTO {domain_access} (nid, gid, realm) VALUES (%d, %d, '%s')", $nid->nid, 0, 'domain_editor');
}
}
}
}
// Rebuild the node access table with our rules.
node_access_rebuild();
// Set the default 'domain_all' grant for special pages.
domain_set_default_grant();
}