Skip to content

Commit

Permalink
fix(issue): properly set validation data on ticket restore
Browse files Browse the repository at this point in the history
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 <tbugier@teclib.com>
  • Loading branch information
btry committed May 19, 2020
1 parent 55df553 commit 0631ece
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0631ece

Please sign in to comment.