Improved new export-import by including user to project binds.
authorNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 20:27:17 +0000 (20:27 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 20:27:17 +0000 (20:27 +0000)
WEB-INF/lib/ttGroupExportHelper.class.php
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/templates/footer.tpl

index 4a2eb78..125df0f 100644 (file)
@@ -309,6 +309,21 @@ class ttGroupExportHelper {
     }
     fwrite($this->file, $this->indentation."  </users>\n");
 
+    // Write user to project binds.
+    fwrite($this->file, $this->indentation."  <user_project_binds>\n");
+    $user_binds = ttTeamHelper::getUserToProjectBinds($this->group_id);
+    foreach ($user_binds as $bind) {
+      $user_id = $this->userMap[$bind['user_id']];
+      $project_id = $this->projectMap[$bind['project_id']];
+      $bind_part = $this->indentation.'    '."<user_project_bind user_id=\"".$user_id."\"";
+      $bind_part .= " project_id=\"".$project_id."\"";
+      $bind_part .= " rate=\"".$bind['rate']."\"";
+      $bind_part .= " status=\"".$bind['status']."\"";
+      $bind_part .= "></user_project_bind>\n";
+      fwrite($this->file, $bind_part);
+    }
+    fwrite($this->file, $this->indentation."  </user_project_binds>\n");
+
     // Call self recursively for all subgroups.
     foreach ($this->subgroups as $subgroup) {
       $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.'  ');
index 06d205e..ccdc05b 100644 (file)
@@ -238,12 +238,23 @@ class ttOrgImportHelper {
           'rate' => $attrs['RATE'],
           'email' => $attrs['EMAIL'],
           'status' => $attrs['STATUS']), false);
-        // TODO: what about created_by and other audit info?
         if ($user_id) {
           // Add a mapping.
           $this->currentGroupUserMap[$attrs['ID']] = $user_id;
         } else $this->errors->add($i18n->get('error.db'));
       }
+
+      if ($name == 'USER_PROJECT_BIND') {
+        if (!ttUserHelper::insertBind(array(
+          'user_id' => $this->currentGroupUserMap[$attrs['USER_ID']],
+          'project_id' => $this->currentGroupProjectMap[$attrs['PROJECT_ID']],
+          'group_id' => $this->current_group_id,
+          'org_id' => $this->org_id,
+          'rate' => $attrs['RATE'],
+          'status' => $attrs['STATUS']))) {
+          $this->errors->add($i18n->get('error.db'));
+        }
+      }
     }
   }
 
index 931ae5f..cff8822 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.4408 | 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.4409 | 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>