Improved new export-import by including all group attributes.
authorNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 18:15:11 +0000 (18:15 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 10 Nov 2018 18:15:11 +0000 (18:15 +0000)
WEB-INF/lib/ttGroupExportHelper.class.php
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/templates/footer.tpl

index 054c435..4a2eb78 100644 (file)
@@ -71,7 +71,7 @@ class ttGroupExportHelper {
     global $user;
     $mdb2 = getConnection();
 
-    $sql =  "select name, currency, lang from tt_groups".
+    $sql =  "select * from tt_groups".
             " where status = 1 and id = $this->group_id and org_id = $user->org_id";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
@@ -177,8 +177,23 @@ class ttGroupExportHelper {
     $group = $this->getGroupData();
     $group_part = "<group name=\"".htmlentities($group['name'])."\"";
     $group_part .= " currency=\"".htmlentities($group['currency'])."\"";
+    $group_part .= " decimal_mark=\"".$group['decimal_mark']."\"";
     $group_part .= " lang=\"".$group['lang']."\"";
-    // TODO: add other group attributes here.
+    $group_part .= " date_format=\"".$group['date_format']."\"";
+    $group_part .= " time_format=\"".$group['time_format']."\"";
+    $group_part .= " week_start=\"".$group['week_start']."\"";
+    $group_part .= " tracking_mode=\"".$group['tracking_mode']."\"";
+    $group_part .= " project_required=\"".$group['project_required']."\"";
+    $group_part .= " task_required=\"".$group['task_required']."\"";
+    $group_part .= " record_type=\"".$group['record_type']."\"";
+    $group_part .= " bcc_email=\"".$group['bcc_email']."\"";
+    $group_part .= " allow_ip=\"".$group['allow_ip']."\"";
+    $group_part .= " password_complexity=\"".$group['password_complexity']."\"";
+    $group_part .= " plugins=\"".$group['plugins']."\"";
+    $group_part .= " lock_spec=\"".$group['lock_spec']."\"";
+    $group_part .= " workday_minutes=\"".$group['workday_minutes']."\"";
+    $group_part .= " custom_logo=\"".$group['custom_logo']."\"";
+    $group_part .= " config=\"".$group['config']."\"";
     $group_part .= ">\n";
 
     // Write group info.
index 6519ffa..06d205e 100644 (file)
@@ -86,8 +86,23 @@ class ttOrgImportHelper {
           'org_id' => $this->org_id,
           'name' => $attrs['NAME'],
           'currency' => $attrs['CURRENCY'],
-          'lang' => $attrs['LANG']));
-        // We only have 3 properties at the moment, while work is ongoing...
+          'decimal_mark' => $attrs['DECIMAL_MARK'],
+          'lang' => $attrs['LANG'],
+          'date_format' => $attrs['DATE_FORMAT'],
+          'time_format' => $attrs['TIME_FORMAT'],
+          'week_start' => $attrs['WEEK_START'],
+          'tracking_mode' => $attrs['TRACKING_MODE'],
+          'project_required' => $attrs['PROJECT_REQUIRED'],
+          'task_required' => $attrs['TASK_REQUIRED'],
+          'record_type' => $attrs['RECORD_TYPE'],
+          'bcc_email' => $attrs['BCC_EMAIL'],
+          'allow_ip' => $attrs['ALLOW_IP'],
+          'password_complexity' => $attrs['PASSWORD_COMPLEXITY'],
+          'plugins' => $attrs['PLUGINS'],
+          'lock_spec' => $attrs['LOCK_SPEC'],
+          'workday_minutes' => $attrs['WORKDAY_MINUTES'],
+          'custom_logo' => $attrs['CUSTOM_LOGO'],
+          'config' => $attrs['CONFIG']));
 
         // Special handling for top group.
         if (!$this->org_id && $this->current_group_id) {
@@ -217,7 +232,7 @@ class ttOrgImportHelper {
           'org_id' => $this->org_id,
           'role_id' => $role_id,
           'client_id' => $this->currentGroupClientMap[$attrs['CLIENT_ID']],
-          'name' => $attrs['NAME'], // TODO: check if we need to decode all such things from htmlentities back. Refactor from the beginning if necessary.
+          'name' => $attrs['NAME'],
           'login' => $attrs['LOGIN'],
           'password' => $attrs['PASSWORD'],
           'rate' => $attrs['RATE'],
@@ -346,24 +361,22 @@ class ttOrgImportHelper {
 
   // createGroup function creates a new group.
   private function createGroup($fields) {
-
+    global $user;
     global $i18n;
     $mdb2 = getConnection();
 
-    $columns = '(parent_id, org_id, name, currency, lang)';
-
-//    $columns = '(name, currency, decimal_mark, lang, date_format, time_format, week_start, tracking_mode'.
-//      ', project_required, task_required, record_type, bcc_email, allow_ip, password_complexity, plugins'.
-//      ', lock_spec, workday_minutes, config, created, created_ip, created_by)';
+    $columns = '(parent_id, org_id, name, currency, decimal_mark, lang, date_format, time_format'.
+      ', week_start, tracking_mode, project_required, task_required, record_type, bcc_email'.
+      ', allow_ip, password_complexity, plugins, lock_spec'.
+      ', workday_minutes, config, created, created_ip, created_by)';
 
     $values = ' values (';
     $values .= $mdb2->quote($fields['parent_id']);
     $values .= ', '.$mdb2->quote($fields['org_id']);
     $values .= ', '.$mdb2->quote(trim($fields['name']));
     $values .= ', '.$mdb2->quote(trim($fields['currency']));
-    //$values .= ', '.$mdb2->quote($fields['decimal_mark']);
+    $values .= ', '.$mdb2->quote($fields['decimal_mark']);
     $values .= ', '.$mdb2->quote($fields['lang']);
-/*
     $values .= ', '.$mdb2->quote($fields['date_format']);
     $values .= ', '.$mdb2->quote($fields['time_format']);
     $values .= ', '.(int)$fields['week_start'];
@@ -378,7 +391,7 @@ class ttOrgImportHelper {
     $values .= ', '.$mdb2->quote($fields['lock_spec']);
     $values .= ', '.(int)$fields['workday_minutes'];
     $values .= ', '.$mdb2->quote($fields['config']);
-    $values .= ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); */
+    $values .= ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id);
     $values .= ')';
 
     $sql = 'insert into tt_groups '.$columns.$values;
index f9a3350..931ae5f 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.4407 | 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.4408 | 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>