// getSubgroups rerurns an array of subgroups for a group.
function getSubgroups($group_id) {
- return array(); // TODO: not yet implemented.
+ $mdb2 = getConnection();
+
+ $subgroups = array();
+ $sql = "select id from tt_groups where parent_id = $group_id";
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $subgroups[] = $val;
+ }
+ }
+ return $subgroups;
}
// getUsers obtains user ids in a group.
return true;
}
- // markGroupDeleted marks the group and everything in it as deleted.
+ // markGroupDeleted marks a group and everything in it as deleted.
function markGroupDeleted($group_id) {
// Keep the logic simple by returning false on first error.
//
// 1) Users may mark some of them deleted during their work.
// If we mark all of them deleted here, we can't recover nicely
- // as we'll lose track of what was deleted by user.
+ // as we'll lose track of what was accidentally deleted by user.
//
- // 2) DB maintenance script (Clean up DB from inactive teams) should
+ // 2) DB maintenance script (Clean up DB from inactive groups) should
// get rid of these items permanently eventually.
// Mark group deleted.
$result = true;
- if (!ttValidString($fields['group_name'], true)) {
+ if (!ttValidString($fields['new_group_name'])) {
$this->err->add($i18n->get('error.field'), $i18n->get('label.group_name'));
$result = false;
}
return true;
}
+
+ // getGroupDetails obtains group name and its top manager details.
+ function getGroupDetails($group_id) {
+ $result = array();
+ $mdb2 = getConnection();
+
+ $sql = "select g.name as group_name, u.id as manager_id, u.name as manager_name, u.login as manager_login, u.email as manager_email".
+ " from tt_groups g".
+ " inner join tt_users u on (u.group_id = g.id)".
+ " inner join tt_roles r on (r.id = u.role_id and r.rank = 512)".
+ " where g.id = $group_id";
+
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ $val = $res->fetchRow();
+ return $val;
+ }
+
+ return false;
+ }
}