function og_subgroups_get_group_parents in Subgroups for Organic groups 6
Retrieve all the parents of a given group
Parameters
$group: A group object
Return value
A keyed array of a groups parents in order from parent to grand parents
4 calls to og_subgroups_get_group_parents()
- og_subgroups_group_tree_json in includes/
json.inc - Generate a group hierarchy tree in JSON format
- og_subgroups_hs_hierarchical_select_lineage in modules/
og_subgroups_hs/ og_subgroups_hs.module - Implementation of hook_hierarchical_select_lineage().
- og_subgroups_views_handler_field_parents::pre_render in modules/
og_subgroups_views/ includes/ og_subgroups_views_handler_field_parents.inc - theme_og_subgroups_menu_tree in includes/
theme.inc - Theme a group hierachy tree
File
- includes/
tree.inc, line 275 - Functions to generate and use the group hierarchy trees
Code
function og_subgroups_get_group_parents($group) {
static $parents;
if (!isset($parents[$group->nid])) {
if ($tree = og_subgroups_get_group_tree($group)) {
$parents[$group->nid] = array();
foreach ($tree as $gid => $branch) {
if ($branch->nid != $group->nid && !empty($branch->children)) {
$object = drupal_clone($branch);
unset($object->children);
if (!isset($branch->children[$group->nid])) {
_og_subgroups_get_group_parents_recursive($group, $branch->children, $parents[$group->nid]);
}
$parents[$group->nid][$branch->nid] = $object;
}
}
}
}
return isset($parents[$group->nid]) ? $parents[$group->nid] : array();
}