Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(mqtlog): compatibility with glpi 9.2
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Oct 20, 2018
1 parent 38f3840 commit aeea7f0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions inc/mqttlog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,20 @@ public static function showMqttLogs(PluginFlyvemdmNotifiableInterface $item) {
public static function findLogs(PluginFlyvemdmNotifiableInterface $item) {
global $DB;

$condition = [
'FIELDS' => ['id', 'date', 'topic', 'message'],
'WHERE' => ['itemtype' => $item::getType(), 'items_id' => $item->getID()],
'GROUPBY' => 'topic',
];

$result = $DB->request(static::getTable(), $condition);
if (version_compare(GLPI_VERSION, '9.3.1') >= 0) {
$condition = [
'FIELDS' => ['id', 'MAX' => ['date as date'], 'topic', 'message'],
'WHERE' => ['itemtype' => $item::getType(), 'items_id' => $item->getID()],
'GROUPBY' => 'topic',
];
$result = $DB->request(static::getTable(), $condition);
} else {
$result = $DB->query("SELECT id, MAX(date) as date, topic, message
FROM " . static::getTable() . "
WHERE itemtype='" . $item::getType() . "' AND items_id = '" . $item->getID() . "'
GROUP BY topic
");
}
return $result;
}
}

0 comments on commit aeea7f0

Please sign in to comment.