function module_grants_get_node_access_result in Module Grants 7
The core function of this module, calculate result for node_access()
1 call to module_grants_get_node_access_result()
- _module_grants_node_access in ./
module_grants.node.inc - Copied from node_access(), with everything before module_invoke_all('node_access') removed (since our override occurs during module_invoke_all('node_access')). Other changes include: 1. Commented out the $rights caching code, we…
File
- ./
module_grants.module, line 191
Code
function module_grants_get_node_access_result($node, $op, $account) {
$module_grants = module_grants_by_module($op, $account);
if (count(array_filter($module_grants)) == 0) {
// if no module has any grants, we'll just add gid = 0 and realm = all condition
$query = _module_grants_get_node_access_query($node, $op);
$query
->condition(db_and()
->condition('gid', 0)
->condition('realm', 'all'));
return (bool) $query
->execute()
->fetchField();
}
else {
foreach ($module_grants as $module => $grants) {
if (variable_get('module_grants_lenient', TRUE) && count(module_grants_get_node_access_realms_for_module($module, $node)) == 0) {
// if a module did not have any grant for this node in node_access table, and we're in lenient mode, then skip this module.
continue;
}
// query copied from node_access(), need to run this for every module
$query = _module_grants_get_node_access_query($node, $op);
$grant_conditions = db_or();
_module_grants_apply_node_access_grants_conditions($module, $grants, $grant_conditions);
$query
->condition($grant_conditions);
$result = (bool) $query
->execute()
->fetchField();
if (!$result) {
return false;
// AND module grants together: break as soon as one fails
}
}
return true;
}
}