You are here

function _og_subgroups_get_tree_recursive in Subgroups for Organic groups 6

Recursive callback to generate a group tree

Parameters

$parent: The parent group

$children: An array of all child groups

Return value

A keyed array of the parents children

See also

_og_subgroups_get_tree()

1 call to _og_subgroups_get_tree_recursive()
_og_subgroups_get_tree in includes/tree.inc
Callback to generate a hierarchy tree of all groups from the database

File

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

Code

function _og_subgroups_get_tree_recursive($parent, $children) {
  $ret = array();

  // Iterate all available children
  foreach ($children as $child) {

    // If this is a child of our parent
    if ($child->parent == $parent->nid) {

      // First gather all of the child's children
      $child->children = _og_subgroups_get_tree_recursive($child, $children);

      // Store the child to be returned
      $ret[$child->nid] = $child;
    }
  }
  return $ret;
}