Skip to content

Commit

Permalink
fix(targetticket,targetchange): covnert question ID into UUID for exp…
Browse files Browse the repository at this point in the history
…ort of target settings

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jul 10, 2020
1 parent 5fb8fd4 commit a17e459
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ public function export($remove_uuid = false) {
} else {
// Convert IDs into UUIDs
$export = $this->convertTags($export);
$questionLinks = [
'due_date_rule' => ['values' => self::DUE_DATE_RULE_ANSWER, 'field' => 'due_date_question'],
'urgency_rule' => ['values' => self::URGENCY_RULE_ANSWER, 'field' => 'urgency_question'],
'tag_type' => ['values' => self::TAG_TYPE_QUESTIONS, 'field' => 'tag_questions'],
'category_rule' => ['values' => self::CATEGORY_RULE_ANSWER, 'field' => 'category_question'],
];
foreach ($questionLinks as $field => $fieldSetting) {
if (!is_array($fieldSetting['values'])) {
$fieldSetting['values'] = [$fieldSetting['values']];
}
if (!in_array($export[$field], $fieldSetting['values'])) {
continue;
}
$question = new PluginFormcreatorQuestion();
$question->getFromDB($export[$fieldSetting['field']]);
$export[$fieldSetting['field']] = $question->fields['uuid'];
}
}
unset($export[$idToRemove]);

Expand Down
20 changes: 20 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,26 @@ public function export($remove_uuid = false) {
} else {
// Convert IDs into UUIDs
$export = $this->convertTags($export);
$questionLinks = [
'type_rule' => ['values' => self::REQUESTTYPE_ANSWER, 'field' => 'type_question'],
'due_date_rule' => ['values' => self::DUE_DATE_RULE_ANSWER, 'field' => 'due_date_question'],
'urgency_rule' => ['values' => self::URGENCY_RULE_ANSWER, 'field' => 'urgency_question'],
'tag_type' => ['values' => self::TAG_TYPE_QUESTIONS, 'field' => 'tag_questions'],
'category_rule' => ['values' => self::CATEGORY_RULE_ANSWER, 'field' => 'category_question'],
'associate_rule' => ['values' => self::ASSOCIATE_RULE_ANSWER, 'field' => 'associate_question'],
'location_rule' => ['values' => self::LOCATION_RULE_ANSWER, 'field' => 'location_question'],
];
foreach ($questionLinks as $field => $fieldSetting) {
if (!is_array($fieldSetting['values'])) {
$fieldSetting['values'] = [$fieldSetting['values']];
}
if (!in_array($export[$field], $fieldSetting['values'])) {
continue;
}
$question = new PluginFormcreatorQuestion();
$question->getFromDB($export[$fieldSetting['field']]);
$export[$fieldSetting['field']] = $question->fields['uuid'];
}
}
unset($export[$idToRemove]);

Expand Down

0 comments on commit a17e459

Please sign in to comment.