You are here

function og_subgroups_get_group_siblings in Subgroups for Organic groups 6

Determine the siblings of a given group

Parameters

$group: The group object

Return value

An array of sibling groups

2 calls to og_subgroups_get_group_siblings()
og_subgroups_context_condition_has_siblings::execute in modules/og_subgroups_context/plugins/og_subgroups_context_condition_has_siblings.inc
Execute the plugin
og_subgroups_views_handler_field_siblings::pre_render in modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc

File

includes/tree.inc, line 369
Functions to generate and use the group hierarchy trees

Code

function og_subgroups_get_group_siblings($group) {
  static $siblings;
  if (!isset($siblings[$group->nid])) {
    if ($tree = og_subgroups_get_group_tree($group)) {
      $siblings[$group->nid] = array();
      foreach ($tree as $gid => $branch) {

        // If the group is the primary parent, then there are no siblings
        if ($group->nid == $gid) {
          continue;
        }
        $siblings[$group->nid] = _og_subgroups_get_group_siblings_recursive($group, $branch);
      }
    }

    // Remove the group from the list of siblings
    unset($siblings[$group->nid][$group->nid]);
  }
  return isset($siblings[$group->nid]) ? $siblings[$group->nid] : array();
}