X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttGroupHelper.class.php;h=44dc3e1b1d3b51070c9c9ac7f3849927c6cfcd5f;hb=7051fc8c0f68618bbaff5f8bb48d3478ce93836a;hp=d28c30670e8eb26c07d91d055f79c977ac51da3e;hpb=f066e7ba4d1141bad2f50e802c0911e5f76e8ef0;p=timetracker.git diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index d28c3067..44dc3e1b 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -36,7 +36,7 @@ class ttGroupHelper { $mdb2 = getConnection(); $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"; + " 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,34 @@ 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; + } + + // The getParentGroup determines a parent group for a given group. + static function getParentGroup($group_id) { + global $user; + + $mdb2 = getConnection(); + + $sql = "select parent_id from tt_groups where id = $group_id and org_id = $user->org_id and status = 1"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + return $val['parent_id']; + } + return false; + } }