X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/87dff6fdf1e60ff60fb429290488cb1c9bf778d9..6e2b1ec1880cebedef5a1ca380820ad0d40d06a2:/WEB-INF/lib/ttUserHelper.class.php diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 538a2fc4..17ef08c2 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -396,12 +396,29 @@ class ttUserHelper { if (!$val) return true; // No limit. $max_count = $val['param_value']; - $sql = "select count(*) as user_count from tt_users where status is not null"; + $sql = "select count(*) as user_count from tt_users where group_id > 0 and status is not null"; $res = $mdb2->query($sql); $val = $res->fetchRow(); - if ($val['user_count'] < $max_count - $num_users) // TODO: test this. + if ($val['user_count'] <= $max_count - $num_users) return true; // Limit not reached. return false; } + + // getUserRank - obtains a rank for a given user. + static function getUserRank($user_id) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select r.rank from tt_users u". + " left join tt_roles r on (u.role_id = r.id)". + " where u.id = $user_id and u.group_id = $group_id and u.org_id = $org_id"; + $res = $mdb2->query($sql); + if (is_a($res, 'PEAR_Error')) return 0; + $val = $res->fetchRow(); + return $val['rank']; + } }