From 799a53be094e99b4285d6e5ce947e915b1f19750 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 12 Sep 2022 10:02:29 +0200 Subject: [eventlog] Improve sample data displaying when editing a filter rule --- modules-available/eventlog/page.inc.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'modules-available/eventlog/page.inc.php') diff --git a/modules-available/eventlog/page.inc.php b/modules-available/eventlog/page.inc.php index b24b9447..ef9870e9 100644 --- a/modules-available/eventlog/page.inc.php +++ b/modules-available/eventlog/page.inc.php @@ -49,14 +49,18 @@ class Page_EventLog extends Page User::assertPermission('filter.rules.edit'); if (Request::any('show') === 'rules') { $type = Request::any('type', Request::REQUIRED, 'string'); - $res = Database::queryFirst('SELECT data FROM notification_sample WHERE type = :type LIMIT 1', + $res = Database::simpleQuery('SELECT data FROM notification_sample + WHERE type = :type ORDER BY dateline DESC LIMIT 5', ['type' => $type]); - Header('Content-Type: application/json'); - if ($res === false) { - echo '{}'; - } else { - echo $res['data']; + $output = []; + foreach ($res as $row) { + $row = json_decode($row['data'], true); + if (is_array($row)) { + $output += $row; + } } + Header('Content-Type: application/json'); + echo json_encode($output); } } -- cgit v1.2.3-55-g7522