You are here

function _og_subgroups_get_field_matching in Subgroups for Organic groups 7.2

Get groups with a a specific value for a field.

Parameters

$group_type: The type of entity.

$group_id: The id of the entity.

$field: The name of the field to test

$value: The value of the field to test.

$key: The specific key for the field.

3 calls to _og_subgroups_get_field_matching()
og_subgroups_children_load_multiple in ./og_subgroups.common.inc
Get the inheriented groups + current group.
og_subgroups_parents_load_multiple in ./og_subgroups.common.inc
Same as og_subgroups_parents_load() but takes in an array of groups.
_og_subgroups_check_access in ./og_subgroups.module
Check access for this group's parents.

File

./og_subgroups.common.inc, line 405
Common functions used in og_subgroups.

Code

function _og_subgroups_get_field_matching($group_type, $gids, $field, $value, $key = 'value') {
  $field_info = field_info_field($field);
  if (empty($field_info)) {
    return array();
  }
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $group_type)
    ->entityCondition('entity_id', $gids)
    ->fieldCondition($field, $key, $value)
    ->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
  $result = $query
    ->execute();
  return !empty($result[$group_type]) ? array_keys($result[$group_type]) : array();
}