]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttOrgImportHelper.class.php
Improved new export-import by adding custom field options.
[timetracker.git] / WEB-INF / lib / ttOrgImportHelper.class.php
index 2cb693445298475bf4a6d65916d4482b21be2ffe..9c39810f2c4b8dc821bbfc8441f524b9462b0f38 100644 (file)
@@ -336,6 +336,26 @@ class ttOrgImportHelper {
           $this->currentGroupCustomFieldMap[$attrs['ID']] = $custom_field_id;
         } else $this->errors->add($i18n->get('error.db'));
       }
+
+      if ($name == 'CUSTOM_FIELD_OPTIONS') {
+        // If we get here, we have to recycle $currentGroupCustomFieldOptionMap.
+        unset($this->currentGroupCustomFieldOptionMap);
+        $this->currentGroupCustomFieldOptionMap = array();
+        // Custom field option map is reconstructed after processing <custom_field_option> elements in XML. See below.
+      }
+
+      if ($name == 'CUSTOM_FIELD_OPTION') {
+        // We get here when processing <custom_field_option> tags for the current group.
+        $custom_field_option_id = ttCustomFieldHelper::insertOption(array(
+          // 'group_id' => $this->current_group_id, TODO: add this when group_id field is added to the table.
+          // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table.
+          'field_id' => $this->currentGroupCustomFieldMap[$attrs['FIELD_ID']],
+          'value' => $attrs['VALUE']));
+        if ($custom_field_option_id) {
+          // Add a mapping.
+          $this->currentGroupCustomFieldOptionMap[$attrs['ID']] = $custom_field_option_id;
+        } else $this->errors->add($i18n->get('error.db'));
+      }
     }
   }