X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttRoleHelper.class.php;h=c324d6805b17f169623c6e895be3a2a9a15d1ff1;hb=a106b7a2db73b3e1fdab428b218212f6f38d7623;hp=c14bc970f45a36d5bc57a6cfdfcf14f4f3a4e157;hpb=b1082e6ec27ca11586bd786b65f509d1a20220f6;p=timetracker.git diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index c14bc970..c324d680 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -102,13 +102,15 @@ class ttRoleHelper { } // getRoleByRank looks up a role by its rank. - static function getRoleByRank($rank, $group_id) { + static function getRoleByRank($rank) { global $user; $mdb2 = getConnection(); - $rank = (int) $rank; // Cast to int just in case for better security. + $group_id = $user->getGroup(); + $org_id = $user->org_id; + $rank = (int) $rank; // Cast to int just in case. - $sql = "select id from tt_roles where group_id = $group_id and rank = $rank and (status = 1 or status = 0)"; + $sql = "select id from tt_roles where group_id = $group_id and org_id = $org_id and rank = $rank and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -173,10 +175,7 @@ class ttRoleHelper { if (is_a($affected, 'PEAR_Error')) return false; - $sql = "SELECT LAST_INSERT_ID() AS last_id"; - $res = $mdb2->query($sql); - $val = $res->fetchRow(); - $last_id = $val['last_id']; + $last_id = $mdb2->lastInsertID('tt_roles', 'id'); return $last_id; }