You are here

function _og_subgroups_get_group_parents_recursive in Subgroups for Organic groups 6

Recursive callback to help determine all parents of a given group

1 call to _og_subgroups_get_group_parents_recursive()
og_subgroups_get_group_parents in includes/tree.inc
Retrieve all the parents of a given group

File

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

Code

function _og_subgroups_get_group_parents_recursive($group, $branch, &$parents) {
  foreach ($branch as $gid => $child) {
    if (isset($child->children[$group->nid])) {
      $object = drupal_clone($child);
      unset($object->children);
      $parents[$child->nid] = $object;
      return TRUE;
    }
    else {
      if (!empty($child->children)) {
        if (_og_subgroups_get_group_parents_recursive($group, $child->children, $parents)) {
          $object = drupal_clone($child);
          unset($object->children);
          $parents[$child->nid] = $object;
          return TRUE;
        }
      }
    }
  }
  return FALSE;
}