Skip to content

Commit

Permalink
Merge branch 'support/2.12.0' of github.com:pluginsglpi/formcreator i…
Browse files Browse the repository at this point in the history
…nto support/2.12.0
  • Loading branch information
btry committed Apr 7, 2022
2 parents 48e7a90 + b05791a commit c9f0f79
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 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,20 @@ 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();
$requester = $requester['users_id'] ?? 0;

$issue->update([
'id' => $issue->getID(),
'items_id' => $id,
Expand All @@ -385,7 +401,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_validator' => $validationStatus['user'],
'comment' => addslashes($item->fields['content']),
]);
Expand Down

0 comments on commit c9f0f79

Please sign in to comment.