I'm using the Domain Access module to restrict content to specific domains. It uses the node_access table to do this.
I also want to make a single node hidden behind a login area. The problem is that when I add my node access rules to do this it overwrites all the Domain Access rules which mean that all the nodes appear on the same domain.
Is there a way to allow more than one module to use node access rules?
My node access code looks like this:
define('MYSITE_REALM', 'press');
define('MYSITE_GRANT_ID_PUBLIC', 0);
define('MYSITE_GRANT_ID_PRESS', 1);
define('MYSITE_PRESS_SECTION_NID', 554);
define('MYSITE_PRESS_USER', 'press');
/**
* Implements hook_node_grants().
*/
function mysite_node_grants($account, $op) {
if ($op == 'view') {
$grants = array();
if ($account->name == MYSITE_PRESS_USER) {
$grants[MYSITE_REALM] = array(
MYSITE_GRANT_ID_PUBLIC,
MYSITE_GRANT_ID_PRESS,
);
}
else {
// everyone else
$grants[MYSITE_REALM] = array(
MYSITE_GRANT_ID_PUBLIC,
);
}
return $grants;
}
}
/**
* Implements hook_access_records().
*/
function mysite_node_access_records($node) {
$grants[] = array();
if ($node->nid == MYSITE_PRESS_SECTION_NID) {
$grants[] = array(
'realm' => MYSITE_REALM,
'gid' => MYSITE_GRANT_ID_PRESS,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
else {
// everything else is public
$grants[] = array(
'realm' => MYSITE_REALM,
'gid' => MYSITE_GRANT_ID_PUBLIC,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 1,
);
}
return $grants;
}
function mysite_user_login(&$edit, $account) {
if ($account->name == MYSITE_PRESS_USER) {
drupal_goto('node/' . MYSITE_PRESS_SECTION_NID);
}
else {
drupal_goto('');
}
}