Skip to content

Commit 326315c

Browse files
committed
fix(target): distinguish fields content
1 parent b10134e commit 326315c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

front/targetticket.form.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545

4646
// Edit an existing target ticket
4747
if (isset($_POST["update"])) {
48-
$target = new PluginFormcreatorTarget();
49-
$found = $target->find('items_id = ' . (int) $_POST['id']);
50-
$found = array_shift($found);
51-
$target->update(['id' => $found['id'], 'name' => $_POST['name']]);
5248
$targetticket->update($_POST);
5349
Html::back();
5450

inc/targetticket.class.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,13 @@ public function prepareInputForUpdate($input) {
924924
$input['uuid'] = plugin_formcreator_getUuid();
925925
}
926926

927+
$target = new PluginFormcreatorTarget();
928+
$found = $target->find('items_id = ' . $this->getID());
929+
$found = array_shift($found);
930+
$target->update(['id' => $found['id'], 'name' => $input['name']]);
931+
$input['name'] = $input['title'];
932+
unset($input['title']);
933+
927934
return $input;
928935
}
929936

@@ -1469,7 +1476,7 @@ public static function import($targetitems_id = 0, $target_data = []) {
14691476
foreach ($rows as $id => $question_line) {
14701477
$uuid = $question_line['uuid'];
14711478

1472-
$content = $target_data['name'];
1479+
$content = $target_data['title'];
14731480
$content = str_replace("##question_$uuid##", "##question_$id##", $content);
14741481
$content = str_replace("##answer_$uuid##", "##answer_$id##", $content);
14751482
$target_data['name'] = $content;
@@ -1561,6 +1568,8 @@ public function export() {
15611568
unset($target_data['id'],
15621569
$target_data['tickettemplates_id']);
15631570

1571+
$target_data['title'] = $target_data['name'];
1572+
unset($target_data['name']);
15641573
return $target_data;
15651574
}
15661575
}

tests/0010_Integration/ExportImportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function _checkTarget($target = []) {
282282
public function _checkTargetTicket($targetticket = []) {
283283
$this->assertArrayNotHasKey('id', $targetticket);
284284
$this->assertArrayNotHasKey('tickettemplates_id', $targetticket);
285-
$this->assertArrayHasKey('name', $targetticket);
285+
$this->assertArrayHasKey('title', $targetticket);
286286
$this->assertArrayHasKey('comment', $targetticket);
287287
$this->assertArrayHasKey('due_date_rule', $targetticket);
288288
$this->assertArrayHasKey('due_date_question', $targetticket);

0 commit comments

Comments
 (0)