X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttGroupHelper.class.php;h=22362b5b901b2bc933c9b00dbeb101540072e7a7;hb=b4be5795ddbcef63b4b6fffb200c3dfc3ffcb530;hp=9fcb8443e889fa847f4ab1f073f8f26397f78a18;hpb=6753e281196a94e8a50d9c98d5195093e61fcefb;p=timetracker.git diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 9fcb8443..22362b5b 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -35,8 +35,8 @@ class ttGroupHelper { $result = array(); $mdb2 = getConnection(); - // TODO: when we have subgroups, improve the query to return only top groups. - $sql = "select id, name, created, lang from tt_teams where status = 1 order by id desc"; + $sql = "select id, name, created, lang from tt_groups". + " where status = 1 and org_id is NULL or org_id = id order by id desc"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -48,4 +48,18 @@ class ttGroupHelper { } return false; } + + // The getGroupName function returns group name. + static function getGroupName($group_id) { + $mdb2 = getConnection(); + + $sql = "select name from tt_groups where id = $group_id and (status = 1 or status = 0)"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + return $val['name']; + } + return false; + } }