File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,8 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
358
358
}
359
359
360
360
function plugin_formcreator_hook_update_ticket (CommonDBTM $ item ) {
361
+ global $ DB ;
362
+
361
363
if (!($ item instanceof Ticket)) {
362
364
return ;
363
365
}
@@ -374,6 +376,24 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
374
376
'items_id ' => $ id
375
377
]
376
378
]);
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
+
377
397
$ issue ->update ([
378
398
'id ' => $ issue ->getID (),
379
399
'items_id ' => $ id ,
@@ -385,7 +405,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
385
405
'date_mod ' => $ item ->fields ['date_mod ' ],
386
406
'entities_id ' => $ item ->fields ['entities_id ' ],
387
407
'is_recursive ' => '0 ' ,
388
- 'requester_id ' => $ item -> fields [ ' users_id_recipient ' ],
408
+ 'requester_id ' => $ requester [ ' users_id ' ],
389
409
'users_id_validator ' => $ validationStatus ['user ' ],
390
410
'comment ' => addslashes ($ item ->fields ['content ' ]),
391
411
]);
You can’t perform that action at this time.
0 commit comments