You are here

function acl_node_access_records in ACL 5

Same name and namespace in other branches
  1. 8 acl.module \acl_node_access_records()
  2. 6 acl.module \acl_node_access_records()
  3. 7 acl.module \acl_node_access_records()

Implementation of hook_node_access_grants (from node_access)

File

./acl.module, line 229
acl.module

Code

function acl_node_access_records($node) {
  if (!$node->nid) {
    return;
  }
  $result = db_query("SELECT n.*, 'acl' AS realm, n.acl_id AS gid, a.module FROM {acl_node} n INNER JOIN {acl} a ON n.acl_id = a.acl_id WHERE nid = %d", $node->nid);
  $grants = array();
  while ($grant = db_fetch_array($result)) {
    if (module_exists($grant['module']) && module_invoke($grant['module'], 'enabled')) {
      if (acl_has_users($grant['gid'])) {
        $grants[] = $grant;
      }
      else {

        //just deny access
        $grants[] = array(
          'grant_view' => 0,
          'realm' => 'acl',
          'gid' => $grant['gid'],
        );
      }
    }
  }
  return $grants;
}