From 109089e858e28200e714a790883c236230b3922f Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 30 Nov 2018 15:09:02 +0000 Subject: [PATCH] Refactored ttRoleHelper::getRoleByRank(). --- WEB-INF/lib/ttOrgImportHelper.class.php | 1 - WEB-INF/lib/ttRoleHelper.class.php | 8 +++++--- WEB-INF/templates/footer.tpl | 2 +- role_add.php | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 060a7c1d..ebb5febd 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -979,7 +979,6 @@ class ttOrgImportHelper { // getTopRole returns top role id. private function getTopRole() { - global $user; $mdb2 = getConnection(); $sql = "select id from tt_roles where group_id = 0 and rank = ".MAX_RANK." and status = 1"; diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index 0686b1cd..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')) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f0d3ff54..3b96b55b 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4547 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4548 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/role_add.php b/role_add.php index 0386e5b1..97883151 100644 --- a/role_add.php +++ b/role_add.php @@ -59,7 +59,7 @@ if ($request->isPost()) { if ($err->no() && ttRoleHelper::getRoleByName($cl_name)) $err->add($i18n->get('error.object_exists')); if ($err->no()) { - $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->group_id); + $existing_role = ttRoleHelper::getRoleByRank($cl_rank); if (!$existing_role) { // Insert a role with default user rights. if (ttRoleHelper::insert(array( -- 2.20.1