Skip to content

Commit 4819b26

Browse files
committed
fix(issue): update issue status on ticket validation update
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent dc82b19 commit 4819b26

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

hook.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,27 @@ function plugin_formcreator_hook_pre_purge_targetChange(CommonDBTM $item) {
446446
$item->pre_purgeItem();
447447
}
448448

449+
function plugin_formcreator_hook_update_ticketvalidation(CommonDBTM $item) {
450+
$ticket = new Ticket();
451+
$ticket->getFromDB($item->fields['tickets_id']);
452+
if ($ticket->isNewItem()) {
453+
// Should not happen
454+
return;
455+
}
456+
457+
$status = PluginFormcreatorCommon::getTicketStatusForIssue($ticket);
458+
459+
$issue = new PluginFormcreatorIssue();
460+
$issue->getFromDBByCrit([
461+
'sub_itemtype' => Ticket::getType(),
462+
'original_id' => $item->fields['tickets_id']
463+
]);
464+
if ($issue->isNewItem()) {
465+
return;
466+
}
467+
$issue->update(['status' => $status['status']] + $issue->fields);
468+
}
469+
449470
function plugin_formcreator_dynamicReport($params) {
450471
switch ($params['item_type']) {
451472
case PluginFormcreatorFormAnswer::class;

setup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ function plugin_init_formcreator() {
154154
$PLUGIN_HOOKS['item_purge']['formcreator'] = [
155155
Ticket::class => 'plugin_formcreator_hook_purge_ticket'
156156
];
157+
$PLUGIN_HOOKS['item_update']['formcreator'] = [
158+
TicketValidation::class => 'plugin_formcreator_hook_update_ticketvalidation'
159+
];
157160
$PLUGIN_HOOKS['pre_item_purge']['formcreator'] = [
158161
PluginFormcreatorTargetTicket::class => 'plugin_formcreator_hook_pre_purge_targetTicket',
159162
PluginFormcreatorTargetChange::class => 'plugin_formcreator_hook_pre_purge_targetChange'

0 commit comments

Comments
 (0)