]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttImportHelper.class.php
Updated ttImportHelper class to populate org_id in newly imported groups.
[timetracker.git] / WEB-INF / lib / ttImportHelper.class.php
index d966f89634359460b78cd0639eda2727dc4e46ce..6686d40f6e7087174f51f17e191c335a78f473c3 100644 (file)
@@ -474,11 +474,18 @@ class ttImportHelper {
 
     $sql = 'insert into tt_groups '.$columns.$values;
     $affected = $mdb2->exec($sql);
-    if (!is_a($affected, 'PEAR_Error')) {
-      $group_id = $mdb2->lastInsertID('tt_groups', 'id');
-      return $group_id;
-    }
-    return false;
+    if (is_a($affected, 'PEAR_Error')) return false;
+
+    $group_id = $mdb2->lastInsertID('tt_groups', 'id');
+
+    // Update org_id with group_id.
+    // NOTE: Both export and import need an additional effort to properly operate on subgroups.
+    // Currently we are importing one group only, which becomes a top level group.
+    $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;
   }
 
   // insertMonthlyQuota - a helper function to insert a monthly quota.