- $val = $res->fetchRow();
- $parent_id = $val['parent_id'];
- if ($parent_id) {
- // Get parent group name.
- $sql = "select name from tt_groups where org_id = $this->org_id and id = $parent_id and status = 1";
- $res = $mdb2->query($sql);
- if (is_a($res, 'PEAR_Error')) return false;
- $val = $res->fetchRow();
- if (!$val) return false;
- array_unshift($groups, array('id'=>$parent_id,'name'=>$val['name']));
- $current_group_id = $parent_id;
- } else {
- return false;
- }
+ $groups[] = array('id'=>$group_id, 'name'=>$name);
+
+ $subgroups = $this->getSubgroups($group_id);
+ foreach($subgroups as $subgroup) {
+ $this->addGroupToDropdown($groups, $subgroup['id'], $subgroup_level+1);