1 node.module node_add_node_grants_to_query($node_access_grants, $table_alias = '')

Helper function to create the OR condition for a node grants check.

@since 1.30.0 Function added.

Parameters

array $node_access_grants: The grants to add to the query, usually gotten via node_access_grants().

string $table_alias: Optional, the alias to the node access table.

Return value

bool: TRUE if the operation may be performed, FALSE otherwise.

Related topics

File

core/modules/node/node.module, line 2697
The core module that allows content to be submitted to the site.

Code

function node_add_node_grants_to_query($node_access_grants, $table_alias = '') {
  $grants = db_or();
  $prefix = $table_alias ? $table_alias . '.' : '';
  foreach ($node_access_grants as $realm => $gids) {
    if (!empty($gids)) {
      $grants->condition(db_and()
        ->condition($prefix . 'gid', $gids, 'IN')
        ->condition($prefix . 'realm', $realm)
        );
    }
  }
  return $grants;
}