Skip to content

Commit

Permalink
fix(issue): requester replaced by author on ticket update
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Mar 29, 2022
1 parent 154a353 commit a8580a7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
}

function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
global $DB;

if (!($item instanceof Ticket)) {
return;
}
Expand All @@ -374,6 +376,24 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
'items_id' => $id
]
]);

// find the 1st requester
$requester = $DB->request([
'SELECT' => 'users_id',
'FROM' => Ticket_User::getTable(),
'WHERE' => [
'tickets_id' => $item->getID(),
'type' => CommonITILActor::REQUESTER,
],
'ORDER' => ['id'],
'LIMIT' => '1',
])->next();
if ($requester === null) {
$requester = [
'users_id' => 0,
];
}

$issue->update([
'id' => $issue->getID(),
'items_id' => $id,
Expand All @@ -385,7 +405,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
'date_mod' => $item->fields['date_mod'],
'entities_id' => $item->fields['entities_id'],
'is_recursive' => '0',
'requester_id' => $item->fields['users_id_recipient'],
'requester_id' => $requester['users_id'],
'users_id_validator' => $validationStatus['user'],
'comment' => addslashes($item->fields['content']),
]);
Expand Down

0 comments on commit a8580a7

Please sign in to comment.