Skip to content

Commit

Permalink
fix(targetticket,targetchange): file dispatch accross several targets…
Browse files Browse the repository at this point in the history
… broken

without this fix all file uploads were added to all targets, ignoring the absence of tag of the file questions

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
btry committed Jul 8, 2021

Unverified

No user is associated with the committer email.
1 parent 6392cdf commit 753b423
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
@@ -1105,19 +1105,16 @@ public function parseTags(string $content, PluginFormcreatorTargetInterface $tar
}

$content = str_replace('##question_' . $questionId . '##', Toolbox::addslashes_deep($name), $content);
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);
if ($target !== null) {
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
$target->addAttachedDocument($documentId);
}
}
if ($question->fields['fieldtype'] === 'file') {
if (strpos($content, '##answer_' . $questionId . '##') !== false) {
if (!is_array($value)) {
$value = [$value];
if ($target !== null) {
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
$target->addAttachedDocument($documentId);
}
}
}
}
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);

if ($this->questionFields[$questionId] instanceof DropdownField) {
$content = $this->questionFields[$questionId]->parseObjectProperties($field->getValueForDesign(), $content);

0 comments on commit 753b423

Please sign in to comment.