You are here

function flag_flag::access_entity_enabled in Flag 7.3

Utility function: Checks whether a flag applies to a certain type, and possibly subtype, of entity.

Parameters

string $entity_type: The type of entity being checked, such as "node".

string|NULL $content_subtype: The subtype being checked. For entities this will be the bundle name (the node type in the case of nodes).

Return value

TRUE if the flag is enabled for this type and subtype.

File

includes/flag/flag_flag.inc, line 633
Contains the flag_flag class. Flag type classes use an object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function access_entity_enabled($entity_type, $content_subtype = NULL) {
  $entity_type_matches = $this->entity_type == $entity_type;
  $sub_type_matches = FALSE;
  if (!isset($content_subtype) || !count($this->types)) {

    // Subtype automatically matches if we're not asked about it,
    // or if the flag applies to all subtypes.
    $sub_type_matches = TRUE;
  }
  else {
    $sub_type_matches = in_array($content_subtype, $this->types);
  }
  return $entity_type_matches && $sub_type_matches;
}