From 0631ece65c05205cf49905740626027871e20123 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 19 May 2020 16:33:07 +0200 Subject: [PATCH] fix(issue): properly set validation data on ticket restore also remove restoration of formanswers : is_deleted column was removed long ago code becomes identical to hook_add_ticket, factorization needed Signed-off-by: Thierry Bugier --- hook.php | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/hook.php b/hook.php index c1b064156..2c3fa649b 100644 --- a/hook.php +++ b/hook.php @@ -417,43 +417,7 @@ function plugin_formcreator_hook_delete_ticket(CommonDBTM $item) { } function plugin_formcreator_hook_restore_ticket(CommonDBTM $item) { - global $DB; - - if ($item instanceof Ticket) { - $id = $item->getID(); - - // Restore deletes form_answers - $iterator = $DB->request([ - 'SELECT' => ['id'], - 'FROM' => Item_Ticket::getTable(), - 'WHERE' => [ - 'itemtype' => 'PluginFormcreatorFormAnswer', - 'tickets_id' => $id, - ] - ]); - foreach ($iterator as $row) { - $form_answer = new PluginFormcreatorFormAnswer(); - $form_answer->update([ - 'id' => $row['id'], - 'is_deleted' => 0, - ]); - } - - $issue = new PluginFormcreatorIssue(); - $issue->add([ - 'original_id' => $item->getID(), - 'sub_itemtype' => 'Ticket', - 'name' => addslashes($item->fields['name']), - 'status' => $item->fields['status'], - 'date_creation' => $item->fields['date'], - 'date_mod' => $item->fields['date_mod'], - 'entities_id' => $item->fields['entities_id'], - 'is_recursive' => '0', - 'requester_id' => $item->fields['users_id_recipient'], - 'validator_id' => '0', - 'comment' => '', - ]); - } + plugin_formcreator_hook_add_ticket($item); } function plugin_formcreator_hook_purge_ticket(CommonDBTM $item) {