From: Nik Okuntseff Date: Thu, 8 Nov 2018 17:04:02 +0000 (+0000) Subject: A bit of refactoring. X-Git-Tag: timetracker_1.19-1~685 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1cfc9f9452a2e397fca1886825fff29fad409e5c;p=timetracker.git A bit of refactoring. --- diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 307be167..ea899821 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -206,13 +206,7 @@ class ttImportHelper { 'status' => $this->currentElement['STATUS'])); } if ($name == 'USER_PROJECT_BIND' && $this->canImport) { -/* - ttUserHelper::insertBind( - $this->userMap[$this->currentElement['USER_ID']], - $this->projectMap[$this->currentElement['PROJECT_ID']], - $this->currentElement['RATE'], - $this->currentElement['STATUS']);*/ - ttUserHelper::insertBind2(array( + ttUserHelper::insertBind(array( 'user_id' => $this->userMap[$this->currentElement['USER_ID']], 'project_id' => $this->projectMap[$this->currentElement['PROJECT_ID']], 'group_id' => $this->group_id, diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index bd5e46b8..222cfdaa 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -229,8 +229,14 @@ class ttUserHelper { if (is_a($affected, 'PEAR_Error')) die ($affected->getMessage()); } else { // Record does not exist. Insert it. - ttUserHelper::insertBind($user_id, $project_id, $rate, 1); - } + ttUserHelper::insertBind(array( + 'user_id' => $user_id, + 'project_id' => $project_id, + 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, + 'rate' => $rate, + 'status' => ACTIVE)); + } } } } @@ -309,20 +315,7 @@ class ttUserHelper { } // insertBind - inserts a user to project bind into tt_user_project_binds table. - static function insertBind($user_id, $project_id, $rate, $status) { - global $user; - $mdb2 = getConnection(); - - $group_id = $user->getActiveGroup(); - $org_id = $user->org_id; - $sql = "insert into tt_user_project_binds (user_id, project_id, group_id, org_id, rate, status)". - " values($user_id, $project_id, $group_id, $org_id, ".$mdb2->quote($rate).", $status)"; - $affected = $mdb2->exec($sql); - return (!is_a($affected, 'PEAR_Error')); - } - - // insertBind2 - inserts a user to project bind into tt_user_project_binds table. - static function insertBind2($fields) { + static function insertBind($fields) { global $user; $mdb2 = getConnection(); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ee8659bf..73feb65a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4388 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4389 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 26f1a33a..d150e735 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -989,6 +989,8 @@ if ($_POST) { setChange("ALTER TABLE `tt_project_task_binds` ADD `group_id` int(11) default NULL AFTER `task_id`"); setChange("ALTER TABLE `tt_project_task_binds` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.12', modified = now() where param_name = 'version_db' and param_value = '1.18.11'"); + // TODO: this does not work as we just introduced group_id and it is NULL. Same for tt_project_task_binds. Improve. + // setChange("UPDATE `tt_user_project_binds` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.12') set org_id = group_id where org_id is null"); } if ($_POST["cleanup"]) {