Skip to content

Commit 2656e28

Browse files
committed
fix(issue): recreate when restore ticket
1 parent 247a574 commit 2656e28

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

hook.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,6 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
344344
return;
345345
}
346346

347-
if (isset($item->input['items_id'][PluginFormcreatorFormAnswer::getType()])) {
348-
// the ticket is associated to a form answer
349-
return;
350-
}
351-
352347
$requester = $DB->request([
353348
'SELECT' => 'users_id',
354349
'FROM' => Ticket_User::getTable(),
@@ -482,15 +477,16 @@ function plugin_formcreator_hook_delete_ticket(CommonDBTM $item) {
482477

483478
function plugin_formcreator_hook_restore_ticket(CommonDBTM $item) {
484479
$formAnswer = new PluginFormcreatorFormAnswer();
485-
if (! $formAnswer->getFromDbByTicket($item)) {
486-
plugin_formcreator_hook_add_ticket($item);
480+
if ($formAnswer->getFromDbByTicket($item)) {
481+
$formAnswer->createIssue();
482+
$minimalStatus = $formAnswer->getAggregatedStatus();
483+
if ($minimalStatus !== null) {
484+
$formAnswer->updateStatus($minimalStatus);
485+
}
487486
return;
488487
}
489488

490-
$minimalStatus = $formAnswer->getAggregatedStatus();
491-
if ($minimalStatus !== null) {
492-
$formAnswer->updateStatus($minimalStatus);
493-
}
489+
plugin_formcreator_hook_add_ticket($item);
494490
}
495491

496492
function plugin_formcreator_hook_purge_ticket(CommonDBTM $item) {

inc/formanswer.class.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,9 @@ public function post_addItem() {
11021102
return;
11031103
}
11041104
}
1105-
$this->createIssue();
1105+
if ($this->input['status'] != self::STATUS_REFUSED) {
1106+
$this->createIssue();
1107+
}
11061108
$minimalStatus = $formAnswer->getAggregatedStatus();
11071109
if ($minimalStatus !== null) {
11081110
$this->updateStatus($minimalStatus);
@@ -1346,14 +1348,9 @@ private function sendNotification() {
13461348
}
13471349
}
13481350

1349-
private function createIssue() {
1351+
public function createIssue() {
13501352
global $DB;
13511353

1352-
$issue = new PluginFormcreatorIssue();
1353-
if ($this->input['status'] == self::STATUS_REFUSED) {
1354-
return;
1355-
}
1356-
13571354
// If cannot get itemTicket from DB it happens either
13581355
// when no item exist
13591356
// or when several rows matches
@@ -1377,6 +1374,8 @@ private function createIssue() {
13771374
'items_id' => $this->getID(),
13781375
]
13791376
]);
1377+
1378+
$issue = new PluginFormcreatorIssue();
13801379
if ($rows->count() != 1) {
13811380
// There is no or several tickets for this form answer
13821381
// The issue must be created from this form answer

0 commit comments

Comments
 (0)