You are here

function flag_node::type_access_multiple in Flag 7.3

Same name and namespace in other branches
  1. 6.2 flag.inc \flag_node::type_access_multiple()
  2. 7.2 flag.inc \flag_node::type_access_multiple()

Implements access_multiple() implemented by each child class.

@abstract

Return value

An array keyed by entity ids, whose values represent the access to the corresponding entity. The access value may be FALSE if access should be denied, or NULL (or not set) if there is no restriction to be made. It should NOT be TRUE.

Overrides flag_flag::type_access_multiple

File

includes/flag/flag_node.inc, line 66
Contains the flag_node class.

Class

flag_node
Implements a node flag.

Code

function type_access_multiple($entity_ids, $account) {
  $access = array();

  // If all subtypes are allowed, we have nothing to say here.
  if (empty($this->types)) {
    return $access;
  }

  // Ensure that only flaggable node types are granted access. This avoids a
  // node_load() on every type, usually done by applies_to_entity_id().
  $result = db_select('node', 'n')
    ->fields('n', array(
    'nid',
  ))
    ->condition('nid', array_keys($entity_ids), 'IN')
    ->condition('type', $this->types, 'NOT IN')
    ->execute();
  foreach ($result as $row) {
    $access[$row->nid] = FALSE;
  }
  return $access;
}