/** * Returns a tree with the children of the root group id * @static * @param int $root_id * @param string $root_name * @param boolean $inclusive * @return unknown */ function getGroupChildrenTree($root_id = null, $root_name = null, $inclusive = true) { global $database, $_VERSION; $tree = ps_perm::getChildGroups('#__core_acl_aro_groups', 'g1.virtuemart_shoppergroup_id, g1.name, COUNT(g2.name) AS level', 'g1.name', $root_id, $root_name, $inclusive); // first pass get level limits $n = count($tree); $min = $tree[0]->level; $max = $tree[0]->level; for ($i = 0; $i < $n; $i++) { $min = min($min, $tree[$i]->level); $max = max($max, $tree[$i]->level); } $indents = array(); foreach (range($min, $max) as $i) { $indents[$i] = ' '; } // correction for first indent $indents[$min] = ''; $list = array(); for ($i = $n - 1; $i >= 0; $i--) { $shim = ''; foreach (range($min, $tree[$i]->level) as $j) { $shim .= $indents[$j]; } if (@$indents[$tree[$i]->level + 1] == '. ') { $twist = ' '; } else { $twist = "- "; } if ($_VERSION->PRODUCT == 'Joomla!' && $_VERSION->RELEASE >= 1.5) { $tree[$i]->virtuemart_shoppergroup_id = $tree[$i]->id; } $list[$tree[$i]->virtuemart_shoppergroup_id] = $shim . $twist . $tree[$i]->name; if ($tree[$i]->level < @$tree[$i - 1]->level) { $indents[$tree[$i]->level + 1] = '. '; } } ksort($list); return $list; }