Improved new import by adding projects.
authorNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 14:29:51 +0000 (14:29 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 14:29:51 +0000 (14:29 +0000)
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/templates/footer.tpl

index 3ccd3a6..f8dbc52 100644 (file)
@@ -29,6 +29,7 @@
 import('ttUserHelper');
 import('ttRoleHelper');
 import('ttTaskHelper');
+import('ttProjectHelper');
 
 // ttOrgImportHelper - this class is a future replacement for ttImportHelper.
 // Currently, it is work in progress.
@@ -47,8 +48,9 @@ class ttOrgImportHelper {
   // var $currentGroupUsers = array(); // Array of arrays of user properties.
 
   // Entity maps for current group. They map XML ids with database ids.
-  var $currentGroupRoleMap = array();
-  var $currentGroupTaskMap = array();
+  var $currentGroupRoleMap    = array();
+  var $currentGroupTaskMap    = array();
+  var $currentGroupProjectMap = array();
   //var $userMap       = array(); // User ids.
   //var $projectMap    = array(); // Project ids.
   //var $taskMap       = array(); // Task ids.
@@ -143,6 +145,34 @@ class ttOrgImportHelper {
           $this->currentGroupTaskMap[$attrs['ID']] = $task_id;
         } else $this->errors->add($i18n->get('error.db'));
       }
+
+      if ($name == 'PROJECTS') {
+        // If we get here, we have to recycle $currentGroupProjectMap.
+        unset($this->currentGroupProjectMap);
+        $this->currentGroupProjectMap = array();
+        // Project map is reconstructed after processing <project> elements in XML. See below.
+      }
+
+      if ($name == 'PROJECT') {
+        // We get here when processing <project> tags for the current group.
+
+        // Prepare a list of task ids.
+        $tasks = explode(',', $attrs['TASKS']);
+        foreach ($tasks as $id)
+          $mapped_tasks[] = $this->currentGroupTaskMap[$id];
+
+        $project_id = ttProjectHelper::insert(array(
+          'group_id' => $this->current_group_id,
+          'org_id' => $this->org_id,
+          'name' => $attrs['NAME'],
+          'description' => $attrs['DESCRIPTION'],
+          'tasks' => $mapped_tasks,
+          'status' => $attrs['STATUS']));
+        if ($project_id) {
+          // Add a mapping.
+          $this->currentGroupProjectMap[$attrs['ID']] = $project_id;
+        } else $this->errors->add($i18n->get('error.db'));
+      }
     }
   }
 
index 9857597..b09112d 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.4403 | 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.4404 | 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>