A bit of refactoring.
authorNik Okuntseff <support@anuko.com>
Thu, 8 Nov 2018 17:04:02 +0000 (17:04 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 8 Nov 2018 17:04:02 +0000 (17:04 +0000)
WEB-INF/lib/ttImportHelper.class.php
WEB-INF/lib/ttUserHelper.class.php
WEB-INF/templates/footer.tpl
dbinstall.php

index 307be16..ea89982 100644 (file)
@@ -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,
index bd5e46b..222cfda 100644 (file)
@@ -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();
 
index ee8659b..73feb65 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.12.4388 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.12.4389 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 26f1a33..d150e73 100644 (file)
@@ -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"]) {