You are here

function _og_subgroups_group_tree_branch_json in Subgroups for Organic groups 6

Recursive callback to return a tree branch in the format needed for JSON

1 call to _og_subgroups_group_tree_branch_json()
og_subgroups_group_tree_json in includes/json.inc
Generate a group hierarchy tree in JSON format

File

includes/json.inc, line 56
JSON callback functions for og subgroups

Code

function _og_subgroups_group_tree_branch_json($group, $branch, $parents) {
  $children = array();
  foreach ($branch as $stem) {
    $expanded = in_array($stem->nid, array_keys($parents)) ? TRUE : FALSE;
    $json = new stdClass();
    $json->text = theme('og_subgroups_menu_tree_link', $group, $stem);
    $json->classes = $group->nid == $stem->nid ? 'og-subgroups-tree-active' : $expanded ? 'open og-subgroups-tree-active-trail' : NULL;
    $json->expanded = $expanded;
    if (!empty($stem->children)) {
      $json->children = _og_subgroups_group_tree_branch_json($group, $stem->children, $parents);
    }
    $children[] = $json;
  }
  return $children;
}