Skip to content

Commit

Permalink
fix(issue): update issue status on ticket validation update
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Sep 16, 2020
1 parent dc82b19 commit 4819b26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,27 @@ function plugin_formcreator_hook_pre_purge_targetChange(CommonDBTM $item) {
$item->pre_purgeItem();
}

function plugin_formcreator_hook_update_ticketvalidation(CommonDBTM $item) {
$ticket = new Ticket();
$ticket->getFromDB($item->fields['tickets_id']);
if ($ticket->isNewItem()) {
// Should not happen
return;
}

$status = PluginFormcreatorCommon::getTicketStatusForIssue($ticket);

$issue = new PluginFormcreatorIssue();
$issue->getFromDBByCrit([
'sub_itemtype' => Ticket::getType(),
'original_id' => $item->fields['tickets_id']
]);
if ($issue->isNewItem()) {
return;
}
$issue->update(['status' => $status['status']] + $issue->fields);
}

function plugin_formcreator_dynamicReport($params) {
switch ($params['item_type']) {
case PluginFormcreatorFormAnswer::class;
Expand Down
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ function plugin_init_formcreator() {
$PLUGIN_HOOKS['item_purge']['formcreator'] = [
Ticket::class => 'plugin_formcreator_hook_purge_ticket'
];
$PLUGIN_HOOKS['item_update']['formcreator'] = [
TicketValidation::class => 'plugin_formcreator_hook_update_ticketvalidation'
];
$PLUGIN_HOOKS['pre_item_purge']['formcreator'] = [
PluginFormcreatorTargetTicket::class => 'plugin_formcreator_hook_pre_purge_targetTicket',
PluginFormcreatorTargetChange::class => 'plugin_formcreator_hook_pre_purge_targetChange'
Expand Down

0 comments on commit 4819b26

Please sign in to comment.