Skip to content

Commit 7bc09ea

Browse files
committed
fix(issue): requester replaced by author on ticket update
1 parent 48e89b4 commit 7bc09ea

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hook.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
372372
}
373373

374374
function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
375+
global $DB;
376+
375377
if (!($item instanceof Ticket)) {
376378
return;
377379
}
@@ -389,6 +391,19 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
389391
]
390392
]);
391393
if (!$issue->isNewItem()) {
394+
// find the 1st requester
395+
$requester = $DB->request([
396+
'SELECT' => 'users_id',
397+
'FROM' => Ticket_User::getTable(),
398+
'WHERE' => [
399+
'tickets_id' => $item->getID(),
400+
'type' => CommonITILActor::REQUESTER,
401+
],
402+
'ORDER' => ['id'],
403+
'LIMIT' => '1',
404+
])->current();
405+
$requester = $requester['users_id'] ?? 0;
406+
392407
$issue->update([
393408
'id' => $issue->getID(),
394409
'items_id' => $id,
@@ -400,7 +415,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
400415
'date_mod' => $item->fields['date_mod'],
401416
'entities_id' => $item->fields['entities_id'],
402417
'is_recursive' => '0',
403-
'requester_id' => $item->fields['users_id_recipient'],
418+
'requester_id' => $requester,
404419
'comment' => addslashes($item->fields['content']),
405420
]);
406421
return;

0 commit comments

Comments
 (0)