Skip to content

Commit c9f0f79

Browse files
committed
Merge branch 'support/2.12.0' of github.com:pluginsglpi/formcreator into support/2.12.0
2 parents 48e7a90 + b05791a commit c9f0f79

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

hook.php

Lines changed: 17 additions & 1 deletion
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,20 @@ 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+
$requester = $requester['users_id'] ?? 0;
392+
377393
$issue->update([
378394
'id' => $issue->getID(),
379395
'items_id' => $id,
@@ -385,7 +401,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
385401
'date_mod' => $item->fields['date_mod'],
386402
'entities_id' => $item->fields['entities_id'],
387403
'is_recursive' => '0',
388-
'requester_id' => $item->fields['users_id_recipient'],
404+
'requester_id' => $requester,
389405
'users_id_validator' => $validationStatus['user'],
390406
'comment' => addslashes($item->fields['content']),
391407
]);

0 commit comments

Comments
 (0)