From 085cb5b327f095bcd55f0764b8ab7b7fb3b6bcfa Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 6 Nov 2018 21:57:37 +0000 Subject: [PATCH] Fixed role_add.php with a check for existing role name. --- WEB-INF/lib/ttReportHelper.class.php | 6 +++--- WEB-INF/lib/ttRoleHelper.class.php | 8 ++++---- WEB-INF/templates/footer.tpl | 2 +- role_add.php | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 744ef97b..76c1765e 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -157,7 +157,7 @@ class ttReportHelper { // Add custom field. $include_cf_1 = $options['show_custom_field_1'] || $grouping_by_cf_1; if ($include_cf_1) { - $custom_fields = new CustomFields($user->group_id); + $custom_fields = new CustomFields($user->getActiveGroup()); $cf_1_type = $custom_fields->fields[0]['type']; if ($cf_1_type == CustomFields::TYPE_TEXT) { array_push($fields, 'cfl.value as cf_1'); @@ -616,7 +616,7 @@ class ttReportHelper { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) - $custom_fields = new CustomFields($user->group_id); + $custom_fields = new CustomFields($user->getActiveGroup()); // Define some styles to use in email. $style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;'; @@ -1460,7 +1460,7 @@ class ttReportHelper { $join .= ' left join tt_tasks t on (l.task_id = t.id)'; } if (ttReportHelper::groupingBy('cf_1', $options)) { - $custom_fields = new CustomFields($user->group_id); + $custom_fields = new CustomFields($user->getActiveGroup()); if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) $join .= ' left join tt_custom_field_log cfl on (l.id = cfl.log_id and cfl.status = 1) left join tt_custom_field_options cfo on (cfl.value = cfo.id)'; elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index e5bf6a7d..2751756b 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -37,7 +37,7 @@ class ttRoleHelper { $mdb2 = getConnection(); $sql = "select id, name, description, rank, rights, status from tt_roles - where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; + where id = $id and group_id = ".$user->getActiveGroup()." and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -56,8 +56,8 @@ class ttRoleHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_roles where group_id = $user->group_id and name = ". - $mdb2->quote($role_name)." and (status = 1 or status = 0)"; + $sql = "select id from tt_roles where group_id = ".$user->getActiveGroup(). + " and name = ".$mdb2->quote($role_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -89,7 +89,7 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); - $sql = "select rights from tt_roles where group_id = $user->group_id and id = $role_id"; + $sql = "select rights from tt_roles where group_id = ".$user->getActiveGroup()." and id = $role_id"; $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 d0d15732..5e48388e 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.08.4378 | Copyright © Anuko | +  Anuko Time Tracker 1.18.08.4379 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/role_add.php b/role_add.php index cb3d6f40..e1e16cc7 100644 --- a/role_add.php +++ b/role_add.php @@ -56,6 +56,7 @@ if ($request->isPost()) { if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); if ($cl_rank >= $user->rank || $cl_rank < 0) $err->add($i18n->get('error.field'), $i18n->get('form.roles.rank')); + 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); -- 2.20.1