From f58ab716cb0cc4b8be8e48723b345bfab29697a6 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 26 Nov 2018 15:54:11 +0000 Subject: [PATCH] Adjusted task_add.php and task_edit.php to operate with subgroups. --- WEB-INF/lib/ttOrgImportHelper.class.php | 8 ++++++-- WEB-INF/lib/ttTaskHelper.class.php | 10 +++++++--- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/task_edit.tpl | 2 ++ task_add.php | 4 ++-- task_edit.php | 5 +++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index ec5593c2..b5a28c8e 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -181,7 +181,9 @@ class ttOrgImportHelper { if ($task_id) { // Add a mapping. $this->currentGroupTaskMap[$attrs['ID']] = $task_id; - } else $this->errors->add($i18n->get('error.db')); + } else { + $this->errors->add($i18n->get('error.db')); + } return; } @@ -205,7 +207,9 @@ class ttOrgImportHelper { if ($project_id) { // Add a mapping. $this->currentGroupProjectMap[$attrs['ID']] = $project_id; - } else $this->errors->add($i18n->get('error.db')); + } else { + $this->errors->add($i18n->get('error.db')); + } return; } diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index c7f25d1a..0d4d5eff 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -35,9 +35,11 @@ class ttTaskHelper { global $user; $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; $sql = "select id, name, description, status from tt_tasks - where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; + where id = $id and group_id = $group_id and org_id = $org_id and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -53,15 +55,17 @@ class ttTaskHelper { // getAssignedProjects - returns an array of projects associatied with a task. static function getAssignedProjects($task_id) { - global $user; + global $user; $result = array(); $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name from tt_projects p inner join tt_project_task_binds ptb on (ptb.project_id = p.id and ptb.task_id = $task_id) - where p.group_id = $user->group_id and p.status = 1 order by p.name"; + where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 20cb8ff3..443e5868 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- +{if $show_projects} +{/if} diff --git a/task_add.php b/task_add.php index 28a554bb..b1ad08a0 100644 --- a/task_add.php +++ b/task_add.php @@ -37,13 +37,13 @@ if (!ttAccessAllowed('manage_tasks')) { header('Location: access_denied.php'); exit(); } -if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { +if (MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) { header('Location: feature_disabled.php'); exit(); } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->group_id); +$projects = ttTeamHelper::getActiveProjects($user->getGroup()); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); diff --git a/task_edit.php b/task_edit.php index 2b91f058..c9f95ecb 100644 --- a/task_edit.php +++ b/task_edit.php @@ -36,7 +36,7 @@ if (!ttAccessAllowed('manage_tasks')) { header('Location: access_denied.php'); exit(); } -if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { +if (MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) { header('Location: feature_disabled.php'); exit(); } @@ -48,7 +48,7 @@ if (!$task) { } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->group_id); +$projects = ttTeamHelper::getActiveProjects($user->getGroup()); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -118,6 +118,7 @@ if ($request->isPost()) { } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('show_projects', count($projects) > 0); $smarty->assign('title', $i18n->get('title.edit_task')); $smarty->assign('content_page_name', 'task_edit.tpl'); $smarty->display('index.tpl'); -- 2.20.1
 Anuko Time Tracker 1.18.28.4522 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4523 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/task_edit.tpl b/WEB-INF/templates/task_edit.tpl index 5af8d935..f8b45a39 100644 --- a/WEB-INF/templates/task_edit.tpl +++ b/WEB-INF/templates/task_edit.tpl @@ -15,10 +15,12 @@ {$i18n.label.status}: {$forms.taskForm.status.control}
{$i18n.label.projects}: {$forms.taskForm.projects.control}
{$i18n.label.required_fields}