From f066e7ba4d1141bad2f50e802c0911e5f76e8ef0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 2 Nov 2018 12:36:58 +0000 Subject: [PATCH 1/1] Started to populate org_id upon group creation. --- WEB-INF/lib/ttGroupHelper.class.php | 2 +- WEB-INF/lib/ttRegistrator.class.php | 14 +++++++++----- WEB-INF/lib/ttUser.class.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 6ffa6b21..d28c3067 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -36,7 +36,7 @@ class ttGroupHelper { $mdb2 = getConnection(); $sql = "select id, name, created, lang from tt_groups". - " where status = 1 and org_id is NULL order by id desc"; + " where status = 1 and org_id is NULL or org_id = id order by id desc"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 6a2142b5..48f4b0aa 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -137,12 +137,16 @@ class ttRegistrator { $sql = "insert into tt_groups (name, currency, lang, created, created_ip) values($name, $currency, $lang, $created, $created_ip)"; $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) return false; - if (!is_a($affected, 'PEAR_Error')) { - $group_id = $mdb2->lastInsertID('tt_groups', 'id'); - return $group_id; - } - return false; + $group_id = $mdb2->lastInsertID('tt_groups', 'id'); + + // Update org_id with group_id. + $sql = "update tt_groups set org_id = $group_id where org_id is NULL and id = $group_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) return false; + + return $group_id; } // The createUser creates a user in database as part of registration process. diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 9ce67ac0..3085a0d5 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -365,7 +365,7 @@ class ttUser { // - A parent group (..) of a currently selected group, if available. // - A currently selected group (.) represented by $behalf_group_id. // - All subgroups (only immediate children) of a currently selected group. - function getGroups($options) { + function getGroups() { $mdb2 = getConnection(); // $sql = 'select id, parent_id, name from tt_groups where org_id = $this->org_id ...'; // TODO: parent_id is now NULL in db, fix this. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index a14235f2..80c89105 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.05.4346 | Copyright © Anuko | +  Anuko Time Tracker 1.18.06.4347 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1