Skip to content

Commit

Permalink
fix(issue): follow entity change on ticket transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 8, 2023
1 parent c3d03b5 commit 434bd35
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,38 @@ function plugin_formcreator_hook_update_user(CommonDBTM $item) {
}
}
}

function plugin_formcreator_transfer(array $options) {
if ($options['type'] != Ticket::class) {
return;
}

if ($options['id'] == $options['newID']) {
$issue = new PluginFormcreatorIssue();
if (!$issue->getFromDbByCrit([
'itemtype' => $options['type'],
'items_id' => $options['id'],
])) {
// No matching issue found
return;
}
$issue->update([
'id' => $issue->getID(),
'entities_id' => $options['entities_id'],
]);
} else {
$item_ticket = new Item_Ticket();
if (!$item_ticket->getFromDBByCrit([
'itemtype' => PluginFormcreatorFormAnswer::class,
'tickets_id' => $options['id'],
])) {
// No matching form answer found
return;
}
$item_ticket->add([
'itemtype' => PluginFormcreatorFormAnswer::class,
'items_id' => $item_ticket->fields['items_id'],
'tickets_id' => $options['newID'],
]);
}
}
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ function plugin_formcreator_permanent_hook(): void {
];
// hook to add custom actions on a ticket in service catalog
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['formcreator'] = 'plugin_formcreator_timelineActions';

$PLUGIN_HOOKS[Hooks::ITEM_TRANSFER]['formcreator'] = 'plugin_formcreator_transfer';

}

/**
Expand Down

0 comments on commit 434bd35

Please sign in to comment.