You are here

public function EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter in Entity reference 7

Implements EntityReferenceHandler::entityFieldQueryAlter().

Overrides EntityReference_SelectionHandler_Generic::entityFieldQueryAlter

File

plugins/selection/EntityReference_SelectionHandler_Generic.class.php, line 360

Class

EntityReference_SelectionHandler_Generic_node
Override for the Node type.

Code

public function entityFieldQueryAlter(SelectQueryInterface $query) {

  // Adding the 'node_access' tag is sadly insufficient for nodes: core
  // requires us to also know about the concept of 'published' and
  // 'unpublished'. We need to do that as long as there are no access control
  // modules in use on the site. As long as one access control module is there,
  // it is supposed to handle this check.
  if (!user_access('bypass node access') && !count(module_implements('node_grants'))) {
    $base_table = $this
      ->ensureBaseTable($query);
    $query
      ->condition("{$base_table}.status", NODE_PUBLISHED);
  }
}