You are here

function _og_subgroups_get_group_parent_recursive in Subgroups for Organic groups 6

Recursive callback to help determine the primary parent of a given group

1 call to _og_subgroups_get_group_parent_recursive()
og_subgroups_get_group_parent in includes/tree.inc
Retrieve the primary parent of a given group

File

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

Code

function _og_subgroups_get_group_parent_recursive($group, $branch) {
  $parent = NULL;
  foreach ($branch as $gid => $child) {
    if (isset($child->children[$group->nid])) {
      return $child;
    }
    else {
      if (!$parent && !empty($child->children)) {
        $parent = _og_subgroups_get_group_parent_recursive($group, $child->children);
      }
    }
  }
  return $parent;
}