You are here

function _module_grants_node_access_view_all_nodes in Module Grants 7

Copied from node_access_view_all_nodes(), changes include: 1. Replace OR query of module grants with a call to module_grants_get_node_access_view_all_nodes_result()

3 calls to _module_grants_node_access_view_all_nodes()
ModuleGrantsEntityTestCase::assertViewAllNodesFunction in module_grants_entity/module_grants_entity.test
module_grants_entity_metadata_node_access in module_grants_entity/module_grants_entity.module
Access callback for the node entity. Copied from entity_metadata_no_hook_node_access() in callbacks.inc
_module_grants_node_query_node_access_alter in ./module_grants.node.inc
Copied from _node_query_node_access_alter(), changes include: 1. Replace calls to node_access_view_all_nodes() with _module_grants_node_access_view_all_nodes() 2. Replace OR query of module grants with a call to…

File

./module_grants.node.inc, line 91
This file contains methods copied from node.module and modified to allow ANDing of grants, which is handled a function call to module_grants_apply_node_access_grants_condition

Code

function _module_grants_node_access_view_all_nodes($account = NULL) {
  global $user;
  if (!$account) {
    $account = $user;
  }

  // Statically cache results in an array keyed by $account->uid.
  $access =& drupal_static(__FUNCTION__);
  if (isset($access[$account->uid])) {
    return $access[$account->uid];
  }

  // If no modules implement the node access system, access is always TRUE.
  if (!module_implements('node_grants')) {
    $access[$account->uid] = TRUE;
  }
  else {

    /*
    $query = db_select('node_access');
    $query->addExpression('COUNT(*)');
    $query
      ->condition('nid', 0)
      ->condition('grant_view', 1, '>=');

    $grants = db_or();
    foreach (node_access_grants('view', $account) as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants->condition(db_and()
            ->condition('gid', $gid)
            ->condition('realm', $realm)
        );
      }
    }
    if (count($grants) > 0 ) {
      $query->condition($grants);
    }

    $access[$account->uid] = $query
      ->execute()
      ->fetchField();
    */
    $access[$account->uid] = module_grants_get_node_access_view_all_nodes_result($account);
  }
  return $access[$account->uid];
}