From: Nik Okuntseff Date: Fri, 2 Nov 2018 12:36:58 +0000 (+0000) Subject: Started to populate org_id upon group creation. X-Git-Tag: timetracker_1.19-1~732 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f066e7ba4d1141bad2f50e802c0911e5f76e8ef0;hp=9def341e72ae78b8d0cb96ce425cdfb6824b00b6;p=timetracker.git Started to populate org_id upon group creation. --- 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}