function og_subgroups_get_family in Subgroups for Organic groups 5
Same name and namespace in other branches
- 5.4 og_subgroups.module \og_subgroups_get_family()
- 5.3 og_subgroups.module \og_subgroups_get_family()
Get the parent/ children for a given group node id.
Parameters
$gid: The group id.
$direction: The direction along the subgroups tree (up/ down, side).
Return value
Array with the parent/ children group id.
6 calls to og_subgroups_get_family()
- og_subgroups_get_all_family in ./
og_subgroups.module - Given a node, this function returns an array of 'group node' objects representing the path in the subroups tree.
- og_subgroups_menu_tree_recurse in ./
og_subgroups.module - Helper function for og_subgroups_menu_tree()
- og_subgroups_nodeapi in ./
og_subgroups.module - Implementation of hook_nodeapi().
- og_subgroups_set_hierarchy in ./
og_subgroups.module - API function to set/ update groups hierarchy.
- og_subgroups_tree_recurse in ./
og_subgroups.module - Helper function for og_subgroups_tree().
File
- ./
og_subgroups.module, line 307 - Maintains subgroups hierarchy created by the orgainc groups module.
Code
function og_subgroups_get_family($gid, $direction) {
$return = array();
if ($direction == 'up') {
$sql_gid = "SELECT ogh.parent AS gid FROM {node} n INNER JOIN {og_subgroups} ogh ON n.nid = ogh.gid WHERE n.nid = %d";
}
else {
$sql_gid = "SELECT ogh.gid FROM {node} n INNER JOIN {og_subgroups} ogh ON n.nid = ogh.parent WHERE n.nid = %d";
}
$sql_title = "SELECT title FROM {node} WHERE nid = %d";
$family_gid = db_query($sql_gid, $gid);
while ($result_gid = db_fetch_object($family_gid)) {
$family_title = db_query($sql_title, $result_gid->gid);
$result_title = db_fetch_object($family_title);
$return[] = (object) array(
'gid' => $result_gid->gid,
'title' => $result_title->title,
);
}
return $return;
}