Skip to content

Commit 6afe5fe

Browse files
committed
feat(targetticket): compatibility with GLPI 9.4
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent c08e299 commit 6afe5fe

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

inc/targetticket.class.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,13 +1368,27 @@ public function save(PluginFormcreatorFormAnswer $formanswer) {
13681368
$use_mailing = PluginFormcreatorCommon::isNotificationEnabled();
13691369
PluginFormcreatorCommon::setNotification(false);
13701370

1371-
$ticketFollowup = new TicketFollowup();
1372-
$ticketFollowup->add([
1373-
'tickets_id' => $ticketID,
1374-
'date' => $_SESSION['glpi_currenttime'],
1375-
'users_id' => $_SESSION['glpiID'],
1376-
'content' => $message
1377-
]);
1371+
$followUpInput = [
1372+
'date' => $_SESSION['glpi_currenttime'],
1373+
'users_id' => Session::getLoginUserID(),
1374+
'content' => $message,
1375+
];
1376+
if (class_exists(ITILFollowup::class)) {
1377+
// GLPI 9.4+
1378+
$followUpInput += [
1379+
'items_id' => $ticketID,
1380+
'itemtype' => Ticket::class,
1381+
];
1382+
$ticketFollowup = new ITILFollowup();
1383+
$ticketFollowup->add($followUpInput);
1384+
} else {
1385+
// GLPI < 9.4
1386+
$followUpInput += [
1387+
'tickets_id' => $ticketID,
1388+
];
1389+
$ticketFollowup = new TicketFollowup();
1390+
$ticketFollowup->add($followUpInput);
1391+
}
13781392

13791393
// Restore mail notification setting
13801394
PluginFormcreatorCommon::setNotification($use_mailing);

0 commit comments

Comments
 (0)