Skip to content

Commit eca75f2

Browse files
committed
fix(targetticket): fix tags handling
1 parent d987243 commit eca75f2

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

inc/field.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function prepareQuestionInputForSave($input) {
6767
return $input;
6868
}
6969

70-
public function getValueForTarget() {
71-
return Toolbox::addslashes_deep($this->value);
70+
public function getRawValue() {
71+
return $this->value;
7272
}
7373

7474
/**

inc/fields/dropdownfield.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ public function getValueForTargetText($richText) {
350350
return Toolbox::addslashes_deep($value);
351351
}
352352

353-
354353
public function getDocumentsForTarget() {
355354
return [];
356355
}

inc/fields/tagfield.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public function getValueForDesign() {
103103
return implode("\r\n", $this->value);
104104
}
105105

106+
public function getValueForTargetText($richText) {
107+
$value = Dropdown::getDropdownName(PluginTagTag::getTable(), $this->value);
108+
return Toolbox::addslashes_deep($value);
109+
}
110+
106111
public function isValid() {
107112
// If the field is required it can't be empty
108113
if ($this->isRequired() && $this->value == '') {

inc/targetbase.class.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ function change_tag_type() {
973973
echo '<div id="tag_specific_value" style="display: none">';
974974

975975
$result = $DB->request([
976-
'SELECT' => ['name'],
976+
'SELECT' => ['id', 'name'],
977977
'FROM' => PluginTagTag::getTable(),
978978
'WHERE' => [
979979
'AND' => [
@@ -1843,15 +1843,25 @@ protected function saveTags(PluginFormcreatorFormanswer $formanswer, $targetId)
18431843
$formAnswerFk = PluginFormcreatorFormAnswer::getForeignKeyField();
18441844
$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
18451845
$result = $DB->request([
1846-
'SELECT' => ['answer'],
1846+
'SELECT' => ['plugin_formcreator_questions_id', 'answer'],
18471847
'FROM' => PluginFormcreatorAnswer::getTable(),
18481848
'WHERE' => [
18491849
$formAnswerFk => [(int) $formanswer->fields['id']],
18501850
$questionFk => $this->fields['tag_questions']
18511851
],
18521852
]);
18531853
foreach ($result as $line) {
1854-
$tab = json_decode($line['answer']);
1854+
$question = new PluginFormcreatorQuestion();
1855+
$question->getFromDB($line['plugin_formcreator_questions_id']);
1856+
$field = PluginFormcreatorFields::getFieldInstance(
1857+
$question->fields['fieldtype'],
1858+
$question
1859+
);
1860+
$field->deserializeValue($line['answer']);
1861+
$tab = $field->getRawValue();
1862+
if (is_integer($tab)) {
1863+
$tab = [$tab];
1864+
}
18551865
if (is_array($tab)) {
18561866
$tags = array_merge($tags, $tab);
18571867
}

inc/targetticket.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public function prepareInputForUpdate($input) {
404404
}
405405

406406
$plugin = new Plugin();
407-
if ($plugin->isInstalled('tag') && $plugin->isActivated('tag')) {
407+
if ($plugin->isActivated('tag')) {
408408
$input['tag_questions'] = (!empty($input['_tag_questions']))
409409
? implode(',', $input['_tag_questions'])
410410
: '';

0 commit comments

Comments
 (0)