Skip to content

Commit a8580a7

Browse files
committed
fix(issue): requester replaced by author on ticket update
1 parent 154a353 commit a8580a7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

hook.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
358358
}
359359

360360
function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
361+
global $DB;
362+
361363
if (!($item instanceof Ticket)) {
362364
return;
363365
}
@@ -374,6 +376,24 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
374376
'items_id' => $id
375377
]
376378
]);
379+
380+
// find the 1st requester
381+
$requester = $DB->request([
382+
'SELECT' => 'users_id',
383+
'FROM' => Ticket_User::getTable(),
384+
'WHERE' => [
385+
'tickets_id' => $item->getID(),
386+
'type' => CommonITILActor::REQUESTER,
387+
],
388+
'ORDER' => ['id'],
389+
'LIMIT' => '1',
390+
])->next();
391+
if ($requester === null) {
392+
$requester = [
393+
'users_id' => 0,
394+
];
395+
}
396+
377397
$issue->update([
378398
'id' => $issue->getID(),
379399
'items_id' => $id,
@@ -385,7 +405,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
385405
'date_mod' => $item->fields['date_mod'],
386406
'entities_id' => $item->fields['entities_id'],
387407
'is_recursive' => '0',
388-
'requester_id' => $item->fields['users_id_recipient'],
408+
'requester_id' => $requester['users_id'],
389409
'users_id_validator' => $validationStatus['user'],
390410
'comment' => addslashes($item->fields['content']),
391411
]);

0 commit comments

Comments
 (0)