Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.947.2.22 diff -u -p -r1.947.2.22 node.module --- modules/node/node.module 3 Mar 2010 21:36:37 -0000 1.947.2.22 +++ modules/node/node.module 19 Mar 2010 04:52:00 -0000 @@ -2125,6 +2125,10 @@ function _node_access_where_sql($op = 'v * access module should implement hook_node_grants() to provide a grant * list for the user. * + * After the default grants have been loaded, we allow modules to alter + * the grants array by reference. This hook allows for complex business + * logic to be applied when integrating multiple node access modules. + * * @param $op * The operation that the user is trying to perform. * @param $account @@ -2140,7 +2144,12 @@ function node_access_grants($op, $accoun $account = $GLOBALS['user']; } - return array_merge(array('all' => array(0)), module_invoke_all('node_grants', $account, $op)); + // Fetch node access grants from other modules. + $grants = module_invoke_all('node_grants', $account, $op); + // Allow modules to alter the assigned grants. + drupal_alter('node_grants', $grants, $account, $op); + + return array_merge(array('all' => array(0)), $grants); } /** @@ -2188,6 +2197,12 @@ function node_db_rewrite_sql($query, $pr * called by modules whenever something other than a node_save causes * the permissions on a node to change. * + * After the default grants have been loaded, we allow modules to alter + * the grants array by reference. This hook allows for complex business + * logic to be applied when integrating multiple node access modules. + * + * @see hook_node_access_records() + * * This function is the only function that should write to the node_access * table. * @@ -2196,6 +2211,9 @@ function node_db_rewrite_sql($query, $pr */ function node_access_acquire_grants($node) { $grants = module_invoke_all('node_access_records', $node); + // Let modules alter the grants. + drupal_alter('node_access_records', $grants, $node); + // If no grants are set, then use the default grant. if (empty($grants)) { $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0); }