Skip to content

Commit 0631ece

Browse files
committed
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 <[email protected]>
1 parent 55df553 commit 0631ece

File tree

1 file changed

+1
-37
lines changed

1 file changed

+1
-37
lines changed

hook.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -417,43 +417,7 @@ function plugin_formcreator_hook_delete_ticket(CommonDBTM $item) {
417417
}
418418

419419
function plugin_formcreator_hook_restore_ticket(CommonDBTM $item) {
420-
global $DB;
421-
422-
if ($item instanceof Ticket) {
423-
$id = $item->getID();
424-
425-
// Restore deletes form_answers
426-
$iterator = $DB->request([
427-
'SELECT' => ['id'],
428-
'FROM' => Item_Ticket::getTable(),
429-
'WHERE' => [
430-
'itemtype' => 'PluginFormcreatorFormAnswer',
431-
'tickets_id' => $id,
432-
]
433-
]);
434-
foreach ($iterator as $row) {
435-
$form_answer = new PluginFormcreatorFormAnswer();
436-
$form_answer->update([
437-
'id' => $row['id'],
438-
'is_deleted' => 0,
439-
]);
440-
}
441-
442-
$issue = new PluginFormcreatorIssue();
443-
$issue->add([
444-
'original_id' => $item->getID(),
445-
'sub_itemtype' => 'Ticket',
446-
'name' => addslashes($item->fields['name']),
447-
'status' => $item->fields['status'],
448-
'date_creation' => $item->fields['date'],
449-
'date_mod' => $item->fields['date_mod'],
450-
'entities_id' => $item->fields['entities_id'],
451-
'is_recursive' => '0',
452-
'requester_id' => $item->fields['users_id_recipient'],
453-
'validator_id' => '0',
454-
'comment' => '',
455-
]);
456-
}
420+
plugin_formcreator_hook_add_ticket($item);
457421
}
458422

459423
function plugin_formcreator_hook_purge_ticket(CommonDBTM $item) {

0 commit comments

Comments
 (0)