You are here

function og_subgroups_parents_load in Subgroups for Organic groups 7.2

Return an array of all the parent groups, optionally filtered including only the groups that allow for inheritance.

Parameters

$group_type: The group type.

$group_id: The group ID.

$filter: Boolean value for whether to return only groups that allow for inheritance.

$fetch_all: Fetch all ancestors. Set to false for only direct parents.

$include_current: Include the group given in params.

$rest: Reset the cache for this group type/id.

Return value

An array with in the form group type to entity ids.

5 calls to og_subgroups_parents_load()
OgSubgroupsAccessFromDescendanceTestCase::testOgSubgroupsPermissions in ./og_subgroups.test
Use cases:
og_subgroups_clear_caches_for_group in ./og_subgroups.module
Clears out the caches for a given group.
og_subgroups_node_access_records_alter in ./og_subgroups.module
Implements hook_node_access_records_alter().
_og_subgroups_check_access in ./og_subgroups.module
Check access for this group's parents.
_og_subgroups_get_inherited_users in ./og_subgroups.common.inc
Return an array of inherited users from the parent groups that allow for user inheritance.

File

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

Code

function og_subgroups_parents_load($group_type, $group_id, $filter = TRUE, $fetch_all = TRUE, $include_current = FALSE, $reset = FALSE) {
  $groups_all =& drupal_static(__FUNCTION__, array());
  $cid = $group_type . '__' . $group_id . '__' . ($filter ? '1' : '0') . '__' . ($fetch_all ? '1' : '0') . '__' . ($include_current ? '1' : '0');
  if (!isset($groups_all[$cid]) || $reset) {
    $groups_all[$cid] = og_subgroups_parents_load_multiple(array(
      $group_type => array(
        $group_id,
      ),
    ), $filter, $fetch_all, $include_current, $reset);
  }
  return $groups_all[$cid];
}