From 38dd91dcf8a9ecf6b7ceb73a9aabf787b96b6f6e Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 9 Dec 2018 15:41:22 +0000 Subject: [PATCH] More refactoring for subgroups. --- WEB-INF/lib/ttGroupHelper.class.php | 21 +++++++++++++++++++++ WEB-INF/lib/ttTeamHelper.class.php | 17 ----------------- WEB-INF/templates/footer.tpl | 2 +- mobile/project_add.php | 3 +-- mobile/project_edit.php | 3 +-- mobile/tasks.php | 3 ++- mobile/time.php | 3 +-- mobile/time_edit.php | 3 +-- mobile/timer.php | 3 +-- project_add.php | 3 +-- project_edit.php | 3 +-- reports.php | 3 ++- tasks.php | 3 ++- time.php | 3 +-- time_edit.php | 3 +-- week.php | 3 +-- 16 files changed, 38 insertions(+), 41 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 8298627a..801793ff 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -484,4 +484,25 @@ class ttGroupHelper { } return $user_list; } + + // getActiveTasks - returns an array of active tasks for a group. + static function getActiveTasks() + { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description from tt_tasks". + " where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 2aab936a..6aa7b917 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -157,23 +157,6 @@ class ttTeamHelper { return false; } - // getActiveTasks - returns an array of active tasks for a group. - static function getActiveTasks($group_id) - { - $result = array(); - $mdb2 = getConnection(); - - $sql = "select id, name, description from tt_tasks where group_id = $group_id and status = 1 order by upper(name)"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $result[] = $val; - } - } - return $result; - } - // getInactiveTasks - returns an array of inactive tasks for a group. static function getInactiveTasks($group_id) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index dff1dd79..60f6f55c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4620 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4621 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/project_add.php b/mobile/project_add.php index a6ed2e8d..aa3e40f7 100644 --- a/mobile/project_add.php +++ b/mobile/project_add.php @@ -29,7 +29,6 @@ require_once('../initialize.php'); import('form.Form'); import('ttProjectHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); // Access checks. @@ -47,7 +46,7 @@ $users = ttGroupHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->group_id); +$tasks = ttGroupHelper::getActiveTasks(); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; diff --git a/mobile/project_edit.php b/mobile/project_edit.php index ec8c53ba..afe99953 100644 --- a/mobile/project_edit.php +++ b/mobile/project_edit.php @@ -29,7 +29,6 @@ require_once('../initialize.php'); import('form.Form'); import('ttProjectHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); // Access checks. @@ -53,7 +52,7 @@ $users = ttGroupHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->group_id); +$tasks = ttGroupHelper::getActiveTasks(); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; diff --git a/mobile/tasks.php b/mobile/tasks.php index 0667bc3b..67adab04 100644 --- a/mobile/tasks.php +++ b/mobile/tasks.php @@ -29,6 +29,7 @@ require_once('../initialize.php'); import('form.Form'); import('ttTeamHelper'); +import('ttGroupHelper'); // Access checks. if (!(ttAccessAllowed('view_own_tasks') || ttAccessAllowed('manage_tasks'))) { @@ -42,7 +43,7 @@ if (MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) { // End of access checks. if($user->can('manage_tasks')) { - $active_tasks = ttTeamHelper::getActiveTasks($user->getGroup()); + $active_tasks = ttGroupHelper::getActiveTasks(); $inactive_tasks = ttTeamHelper::getInactiveTasks($user->getGroup()); } else $active_tasks = $user->getAssignedTasks(); diff --git a/mobile/time.php b/mobile/time.php index 9e51633b..6bacd084 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -29,7 +29,6 @@ require_once('../initialize.php'); import('form.Form'); import('ttUserHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); @@ -147,7 +146,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 60a14e2c..cdd50707 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -29,7 +29,6 @@ require_once('../initialize.php'); import('form.Form'); import('ttUserHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); @@ -164,7 +163,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/mobile/timer.php b/mobile/timer.php index 184e6274..73035a39 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -29,7 +29,6 @@ require_once('../initialize.php'); import('form.Form'); import('ttUserHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); @@ -145,7 +144,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/project_add.php b/project_add.php index 53cad4bc..e8f98883 100644 --- a/project_add.php +++ b/project_add.php @@ -29,7 +29,6 @@ require_once('initialize.php'); import('form.Form'); import('ttProjectHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); // Access checks. @@ -47,7 +46,7 @@ $users = ttGroupHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->getGroup()); +$tasks = ttGroupHelper::getActiveTasks(); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; diff --git a/project_edit.php b/project_edit.php index 14f319e9..7f48c910 100644 --- a/project_edit.php +++ b/project_edit.php @@ -29,7 +29,6 @@ require_once('initialize.php'); import('form.Form'); import('ttProjectHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); // Access checks. @@ -53,7 +52,7 @@ $users = ttGroupHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->getGroup()); +$tasks = ttGroupHelper::getActiveTasks(); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; diff --git a/reports.php b/reports.php index f4306961..31209995 100644 --- a/reports.php +++ b/reports.php @@ -31,6 +31,7 @@ import('form.Form'); import('form.ActionForm'); import('DateAndTime'); import('ttTeamHelper'); +import('ttGroupHelper'); import('Period'); import('ttProjectHelper'); import('ttFavReportHelper'); @@ -106,7 +107,7 @@ $form->addInput(array('type'=>'combobox', 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.all')))); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/tasks.php b/tasks.php index 6c79fd50..49d126f0 100644 --- a/tasks.php +++ b/tasks.php @@ -29,6 +29,7 @@ require_once('initialize.php'); import('form.Form'); import('ttTeamHelper'); +import('ttGroupHelper'); // Access checks. if (!(ttAccessAllowed('view_own_tasks') || ttAccessAllowed('manage_tasks'))) { @@ -73,7 +74,7 @@ if ($user->can('manage_subgroups')) { } if($user->can('manage_tasks')) { - $active_tasks = ttTeamHelper::getActiveTasks($group_id); + $active_tasks = ttGroupHelper::getActiveTasks(); $inactive_tasks = ttTeamHelper::getInactiveTasks($group_id); } else $active_tasks = $user->getAssignedTasks(); diff --git a/time.php b/time.php index a428b9a2..06665310 100644 --- a/time.php +++ b/time.php @@ -30,7 +30,6 @@ require_once('initialize.php'); import('form.Form'); import('ttUserHelper'); import('ttGroupHelper'); -import('ttTeamHelper'); import('ttClientHelper'); import('ttTimeHelper'); import('DateAndTime'); @@ -224,7 +223,7 @@ if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $use } if (MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { - $task_list = ttTeamHelper::getActiveTasks($group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/time_edit.php b/time_edit.php index 4b3f4c2c..16f69d2a 100644 --- a/time_edit.php +++ b/time_edit.php @@ -29,7 +29,6 @@ require_once('initialize.php'); import('form.Form'); import('ttUserHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); import('ttClientHelper'); import('ttTimeHelper'); @@ -167,7 +166,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/week.php b/week.php index 289d9512..edba8996 100644 --- a/week.php +++ b/week.php @@ -32,7 +32,6 @@ import('form.DefaultCellRenderer'); import('form.Table'); import('form.TextField'); import('ttUserHelper'); -import('ttTeamHelper'); import('ttGroupHelper'); import('ttWeekViewHelper'); import('ttClientHelper'); @@ -299,7 +298,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->group_id); + $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', -- 2.20.1