From a711e76851f29c7e0ac290a279eb4dd984ea7167 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 7 Nov 2018 14:12:04 +0000 Subject: [PATCH] Started populating org_id in projects and tasks. --- WEB-INF/lib/ttImportHelper.class.php | 2 ++ WEB-INF/lib/ttProjectHelper.class.php | 5 +++-- WEB-INF/lib/ttTaskHelper.class.php | 5 +++-- WEB-INF/templates/footer.tpl | 2 +- dbinstall.php | 2 ++ mobile/project_add.php | 3 ++- mobile/project_edit.php | 3 ++- mobile/task_add.php | 3 ++- mobile/task_edit.php | 3 ++- project_add.php | 3 ++- project_edit.php | 3 ++- task_add.php | 3 ++- task_edit.php | 3 ++- 13 files changed, 27 insertions(+), 13 deletions(-) diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index e732b989..350b0c1f 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -184,6 +184,7 @@ class ttImportHelper { $this->taskMap[$this->currentElement['ID']] = ttTaskHelper::insert(array( 'group_id' => $this->group_id, + 'org_id' => $this->org_id, 'name' => $this->currentElement['NAME'], 'description' => $this->currentElement['DESCRIPTION'], 'status' => $this->currentElement['STATUS'])); @@ -198,6 +199,7 @@ class ttImportHelper { $this->projectMap[$this->currentElement['ID']] = ttProjectHelper::insert(array( 'group_id' => $this->group_id, + 'org_id' => $this->org_id, 'name' => $this->currentElement['NAME'], 'description' => $this->currentElement['DESCRIPTION'], 'tasks' => $mapped_tasks, diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index 9203b560..72b71711 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -189,6 +189,7 @@ class ttProjectHelper { $mdb2 = getConnection(); $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $name = $fields['name']; $description = $fields['description']; @@ -197,8 +198,8 @@ class ttProjectHelper { $comma_separated = implode(',', $tasks); // This is a comma-separated list of associated task ids. $status = $fields['status']; - $sql = "insert into tt_projects (group_id, name, description, tasks, status) - values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_projects (group_id, org_id, name, description, tasks, status) + values ($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index b02271b9..b4644d51 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -136,13 +136,14 @@ class ttTaskHelper { $mdb2 = getConnection(); $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $name = $fields['name']; $description = $fields['description']; $projects = $fields['projects']; $status = $fields['status']; - $sql = "insert into tt_tasks (group_id, name, description, status) - values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_tasks (group_id, org_id, name, description, status) + values ($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); $last_id = 0; if (is_a($affected, 'PEAR_Error')) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f36602e5..8da3be0e 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.10.4382 | Copyright © Anuko | +  Anuko Time Tracker 1.18.10.4383 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index a4a6eba7..e77c24b9 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -977,6 +977,8 @@ if ($_POST) { setChange("ALTER TABLE `tt_projects` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("ALTER TABLE `tt_tasks` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.10', modified = now() where param_name = 'version_db' and param_value = '1.18.09'"); + setChange("UPDATE `tt_projects` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.10') set org_id = group_id where org_id is null"); + setChange("UPDATE `tt_tasks` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.10') set org_id = group_id where org_id is null"); } if ($_POST["cleanup"]) { diff --git a/mobile/project_add.php b/mobile/project_add.php index b0d5394d..6d68a178 100644 --- a/mobile/project_add.php +++ b/mobile/project_add.php @@ -78,7 +78,8 @@ if ($request->isPost()) { if ($err->no()) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/mobile/project_edit.php b/mobile/project_edit.php index 94f3e514..defec7ad 100644 --- a/mobile/project_edit.php +++ b/mobile/project_edit.php @@ -119,7 +119,8 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/mobile/task_add.php b/mobile/task_add.php index 4b257edc..796c725c 100644 --- a/mobile/task_add.php +++ b/mobile/task_add.php @@ -68,7 +68,8 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => ACTIVE, diff --git a/mobile/task_edit.php b/mobile/task_edit.php index f1e25689..030cacd1 100644 --- a/mobile/task_edit.php +++ b/mobile/task_edit.php @@ -103,7 +103,8 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => $cl_status, diff --git a/project_add.php b/project_add.php index 98087025..3b4c73d3 100644 --- a/project_add.php +++ b/project_add.php @@ -77,7 +77,8 @@ if ($request->isPost()) { if ($err->no()) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/project_edit.php b/project_edit.php index 14e8e771..77312b0b 100644 --- a/project_edit.php +++ b/project_edit.php @@ -118,7 +118,8 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/task_add.php b/task_add.php index e25fa390..383a3935 100644 --- a/task_add.php +++ b/task_add.php @@ -68,7 +68,8 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => ACTIVE, diff --git a/task_edit.php b/task_edit.php index feff4e52..e6381731 100644 --- a/task_edit.php +++ b/task_edit.php @@ -101,7 +101,8 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->group_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => $cl_status, -- 2.20.1