You are here

function _module_grants_get_node_access_query in Module Grants 7

1 call to _module_grants_get_node_access_query()
module_grants_get_node_access_result in ./module_grants.module
The core function of this module, calculate result for node_access()

File

./module_grants.module, line 228

Code

function _module_grants_get_node_access_query($node, $op) {
  $query = db_select('node_access');
  $query
    ->addExpression('1');
  $query
    ->condition('grant_' . $op, 1, '>=');
  $nids = db_or()
    ->condition('nid', $node->nid);
  if ($node->status) {
    $nids
      ->condition('nid', 0);
  }
  $query
    ->condition($nids);
  $query
    ->range(0, 1);
  return $query;
}