X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/f1c11908a996c1a0d9582ef6d32490e5ce15f02d..72b46840f490f84fc95fcd2c5288fb33e168d44e:/WEB-INF/lib/ttRoleHelper.class.php diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index 7e0f5f69..3ed85c3d 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -83,7 +83,52 @@ class ttRoleHelper { return false; } - // The getRoleID looks up a role by its rank. + // The getLegacyRole obtains a legacy role value for a role_id. + // This is a temporary function to allow usage of both old and new roles + // while new role code is being written and deployed. + static function getLegacyRole($role_id) { + global $user; + $mdb2 = getConnection(); + + $sql = "select rank from tt_roles where team_id = $user->team_id and id = $role_id"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['rank']) { + $rank = $val['rank']; + if ($rank >= ROLE_MANAGER) + return ROLE_MANAGER; + else if ($rank >= ROLE_COMANAGER) + return ROLE_COMANAGER; + else if ($rank >= ROLE_CLIENT) + return ROLE_CLIENT; + else + return ROLE_USER; + } + } + return false; + } + + // isClientRole determines if the role is a "client" role. + // This simply means the role has no "data_entry" right. + static function isClientRole($role_id) { + global $user; + $mdb2 = getConnection(); + + $sql = "select rights from tt_roles where team_id = $user->team_id and id = $role_id"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['rights']) { + return !in_array('data_entry', explode(',', $val['rights'])); + } + } + return false; + } + + // getRoleByRank looks up a role by its rank. static function getRoleByRank($rank) { global $user; $mdb2 = getConnection(); @@ -96,7 +141,7 @@ class ttRoleHelper { if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); if ($val['id']) - return $val; + return $val['id']; } return false; }