From 798ebc01e6c81cc95323de068477711e2b95b9cc Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 12 Sep 2022 10:33:41 +0200 Subject: [syslog] Minor refactor --- modules-available/syslog/page.inc.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'modules-available/syslog') diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php index 71a07e14..cd1c9d4d 100644 --- a/modules-available/syslog/page.inc.php +++ b/modules-available/syslog/page.inc.php @@ -26,20 +26,18 @@ class Page_SysLog extends Page Util::redirect('?do=syslog'); } if (Request::isPost()) { - $search = Request::any('search', false, 'string'); - $filter = Request::any('filter', false, 'string'); - $not = Request::any('not', false, 'bool'); - $machineuuid = Request::any('machineuuid'); - if (empty($search)) { - $search = false; - } - if (empty($filter)) { - $filter = false; + $pairs = []; + foreach (['search', 'filter', 'not', 'machineuuid'] as $key) { + $val = Request::any($key, false, 'string'); + if (!empty($val)) { + if ($key === 'not') { + $val = (bool)$val; + } + $pairs[$key] = $val; + } + Session::set('log_' . $key, $pairs[$key] ?? false, false); } - Session::set('log_search', $search, false); - Session::set('log_filter', $filter, false); - Session::set('log_not', $not, false); - Util::redirect('?do=syslog&' . http_build_query(compact('search', 'filter', 'not', 'machineuuid'))); + Util::redirect('?do=syslog&' . http_build_query($pairs)); } User::assertPermission('*'); } -- cgit v1.2.3-55-g7522