X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/ecbfa220ec9448151166495a3dad39fa97b6c604..1c40fb09e97ff643c80e9b96106d891e6fdbde1b:/WEB-INF/lib/ttRoleHelper.class.php diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index 9abef9df..62d2bafe 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -28,6 +28,40 @@ // The ttRoleHelper is a class to help with custom group roles. class ttRoleHelper { + + // get - gets details of a role identified by its id. + static function get($id) + { + global $user; + + $mdb2 = getConnection(); + + $sql = "select id, name, description, rank, rights, status from tt_roles + where id = $id and team_id = $user->team_id and (status = 0 or status = 1)"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['id'] != '') { + return $val; + } else + return false; + } + return false; + } + + // delete - marks the role as deleted. + static function delete($role_id) { + global $user; + + $mdb2 = getConnection(); + + // Mark the task as deleted. + $sql = "update tt_roles set status = NULL where id = $role_id and team_id = $user->team_id"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } + // insert - inserts an entry into tt_roles table. static function insert($fields) {