Adjusted header.tpl for Work plugin.
[timetracker.git] / WEB-INF / lib / ttOrgExportHelper.class.php
index aa9c905..2dd54f1 100644 (file)
@@ -30,9 +30,8 @@ import('ttTeamHelper');
 import('ttTimeHelper');
 import('ttGroupExportHelper');
 
-// ttOrgExportHelper - this class is a future replacement for ttExportHelper.
-// Currently, it is work in progress.
-// When done, it should handle export of organizations containing multiple groups.
+// ttOrgExportHelper handles export of organizations consisting of multiple groups
+// into XML file for import (migrating) to another server.
 class ttOrgExportHelper {
 
   var $fileName = null; // Name of file with data.
@@ -51,7 +50,8 @@ class ttOrgExportHelper {
 
     // Write XML to the file.
     fwrite($file, "<?xml version=\"1.0\"?>\n");
-    fwrite($file, "<org>\n");
+    $org_part = "<org schema=\"".$this->getVersion()."\">\n";
+    fwrite($file, $org_part);
 
     // Use ttGroupExportHelper to export all groups.
     $groupExportHelper = new ttGroupExportHelper($user->group_id, $file, '  ');  // 2 spaces indentation for home group.
@@ -98,4 +98,16 @@ class ttOrgExportHelper {
     fclose ($in_file);
     return true;
   }
+
+  private function getVersion() {
+    $mdb2 = getConnection();
+    $sql = "select param_value from tt_site_config where param_name = 'version_db'";
+    $res = $mdb2->query($sql);
+    if (!is_a($res, 'PEAR_Error')) {
+      $val = $res->fetchRow();
+      return $val['param_value'];
+        $result[] = $val;
+    }
+    return false;
+  }
 }