function og_subgroups_flatten_tree in Subgroups for Organic groups 6
Flatten the subgroups tree or branch
Parameters
$tree: A tree of group objects
Return value
a flat array of all groups in the tree
3 calls to og_subgroups_flatten_tree()
- og_subgroups_hs_hierarchical_select_item_get_label in modules/
og_subgroups_hs/ og_subgroups_hs.module - Implementation of hook_hierarchical_select_item_get_label().
- og_subgroups_hs_hierarchical_select_valid_item in modules/
og_subgroups_hs/ og_subgroups_hs.module - Implementation of hook_hierarchical_select_valid_item().
- og_subgroups_views_handler_sort_hierarchy::query in modules/
og_subgroups_views/ includes/ og_subgroups_views_handler_sort_hierarchy.inc
File
- includes/
tree.inc, line 438 - Functions to generate and use the group hierarchy trees
Code
function og_subgroups_flatten_tree($tree) {
$flat = array();
foreach ($tree as $gid => $parent) {
$children = og_subgroups_get_group_children($parent, FALSE);
// Remove the children
$object = drupal_clone($parent);
unset($object->children);
// Save the parent and children
$flat[$gid] = $object;
$flat += $children;
}
return $flat;
}