Index: node.module =================================================================== --- node.module (revision 1146) +++ node.module (working copy) @@ -2894,15 +2894,21 @@ if (!$grants) { $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0); } - else { - // retain grants by highest priority - $grant_by_priority = array(); - foreach ($grants as $g) { - $grant_by_priority[intval($g['priority'])][] = $g; - } - krsort($grant_by_priority); - $grants = array_shift($grant_by_priority); + + // Allow modules to customize node_access logic. For example, to AND realms + // together rather than OR them. + foreach (module_implements('node_access_grants_alter') as $module) { + $function = $module .'_node_access_grants_alter'; + $function($node, $grants); } + + // retain grants by highest priority + $grant_by_priority = array(); + foreach ($grants as $g) { + $grant_by_priority[intval($g['priority'])][] = $g; + } + krsort($grant_by_priority); + $grants = array_shift($grant_by_priority); node_access_write_grants($node, $grants); }