From f5db22586748c7c10c6c800c644c4a6d8d2fec3a Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 3 Feb 2023 22:58:37 +0100 Subject: [PATCH] Add new Option "ViewColoredCells" Using this setting, the new colored syslog message cells based on Syslog Severity (Priority) can be enabled or disabled. Default for existing installations is disabled. Default for new installations should be enabled (config.sample.php). --- src/admin/index.php | 5 ++++- src/include/functions_common.php | 2 ++ src/index.php | 6 ++++-- src/lang/en/admin.php | 1 + src/templates/admin/admin_index.html | 9 +++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/admin/index.php b/src/admin/index.php index 8f39e15..5271ba6 100644 --- a/src/admin/index.php +++ b/src/admin/index.php @@ -183,6 +183,7 @@ if ( isset($_POST['op']) ) if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; } if ( isset ($_POST['MiscDebugToSyslog']) ) { $content['MiscDebugToSyslog'] = 1; } else { $content['MiscDebugToSyslog'] = 0; } if ( isset ($_POST['DisableAdminUsers']) ) { $content['DisableAdminUsers'] = 1; } else { $content['DisableAdminUsers'] = 0; } + if ( isset ($_POST['ViewColoredCells']) ) { $content['ViewColoredCells'] = 1; } else { $content['ViewColoredCells'] = 0; } // Read Text number fields if ( isset ($_POST['ViewMessageCharacterLimit']) && is_numeric($_POST['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_POST['ViewMessageCharacterLimit']; } @@ -235,6 +236,7 @@ if ( isset($_POST['op']) ) if ( isset ($_POST['User_DefaultFontSize']) ) { $USERCFG['DefaultFontSize'] = $_POST['User_DefaultFontSize']; } // Read checkboxes + if ( isset( $_POST['User_ViewColoredCells']) ) { $USERCFG['ViewColoredCells'] = 1; } else { $USERCFG['ViewColoredCells'] = 0; } if ( isset ($_POST['User_ViewUseTodayYesterday']) ) { $USERCFG['ViewUseTodayYesterday'] = 1; } else { $USERCFG['ViewUseTodayYesterday'] = 0; } if ( isset ($_POST['User_ViewEnableDetailPopups']) ) { $USERCFG['ViewEnableDetailPopups'] = 1; } else { $USERCFG['ViewEnableDetailPopups'] = 0; } if ( isset ($_POST['User_EnableContextLinks']) ) { $USERCFG['EnableContextLinks'] = 1; } else { $USERCFG['EnableContextLinks'] = 0; } @@ -280,7 +282,7 @@ if ( !isset($content['AdminChangeWaitTime']) ) { $content['AdminChangeWaitTime'] // Set checkbox States if (isset($content['ExportUseTodayYesterday']) && $content['ExportUseTodayYesterday'] == 1) { $content['ExportUseTodayYesterday_checked'] = "checked"; } else { $content['ExportUseTodayYesterday_checked'] = ""; } if (isset($content['SESSION_MAXIMIZED']) && $content['SESSION_MAXIMIZED'] == 1) { $content['SESSION_MAXIMIZED_checked'] = "checked"; } else { $content['SESSION_MAXIMIZED_checked'] = ""; } - +if (isset($content['ViewColoredCells']) && $content['ViewColoredCells'] == 1) { $content['ViewColoredCells_checked'] = "checked"; } else { $content['ViewColoredCells_checked'] = ""; } if (isset($content['ViewUseTodayYesterday']) && $content['ViewUseTodayYesterday'] == 1) { $content['ViewUseTodayYesterday_checked'] = "checked"; } else { $content['ViewUseTodayYesterday_checked'] = ""; } if (isset($content['ViewEnableDetailPopups']) && $content['ViewEnableDetailPopups'] == 1) { $content['ViewEnableDetailPopups_checked'] = "checked"; } else { $content['ViewEnableDetailPopups_checked'] = ""; } if (isset($content['EnableContextLinks']) && $content['EnableContextLinks'] == 1) { $content['EnableContextLinks_checked'] = "checked"; } else { $content['EnableContextLinks_checked'] = ""; } @@ -398,6 +400,7 @@ if ( $content['ENABLEUSEROPTIONS'] ) // Set checkbox States if ( GetConfigSetting('ExportUseTodayYesterday', $content['ExportUseTodayYesterday'], CFGLEVEL_USER) == 1) { $content['User_ExportUseTodayYesterday_checked'] = "checked"; } else { $content['User_ExportUseTodayYesterday_checked'] = ""; } if ( GetConfigSetting('SESSION_MAXIMIZED', $content['SESSION_MAXIMIZED'], CFGLEVEL_USER) == 1) { $content['User_SESSION_MAXIMIZED_checked'] = "checked"; } else { $content['User_SESSION_MAXIMIZED_checked'] = ""; } + if ( GetConfigSetting('ViewColoredCells', $content['ViewColoredCells'], CFGLEVEL_USER) == 1) { $content['User_ViewColoredCells_checked'] = "checked"; } else { $content['User_ViewColoredCells_checked'] = ""; } if ( GetConfigSetting('ViewUseTodayYesterday', $content['ViewUseTodayYesterday'], CFGLEVEL_USER) == 1) { $content['User_ViewUseTodayYesterday_checked'] = "checked"; } else { $content['User_ViewUseTodayYesterday_checked'] = ""; } if ( GetConfigSetting('ViewEnableDetailPopups', $content['ViewEnableDetailPopups'], CFGLEVEL_USER) == 1) { $content['User_ViewEnableDetailPopups_checked'] = "checked"; } else { $content['User_ViewEnableDetailPopups_checked'] = ""; } diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 6597e98..24cac43 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -1795,6 +1795,7 @@ function SaveGeneralSettingsIntoDB($bForceStripSlahes = false) WriteConfigValue( "ExportUseTodayYesterday", true, null, null,$bForceStripSlahes ); WriteConfigValue( "SESSION_MAXIMIZED", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewColoredCells", true, null, null,$bForceStripSlahes ); WriteConfigValue( "ViewUseTodayYesterday", true, null, null,$bForceStripSlahes ); WriteConfigValue( "ViewEnableDetailPopups", true, null, null,$bForceStripSlahes ); @@ -1850,6 +1851,7 @@ function SaveUserGeneralSettingsIntoDB() WriteConfigValue( "ExportUseTodayYesterday", false, $content['SESSION_USERID']); WriteConfigValue( "SESSION_MAXIMIZED", false, $content['SESSION_USERID']); + WriteConfigValue( "ViewColoredCells", false, $content['SESSION_USERID']); WriteConfigValue( "ViewUseTodayYesterday", false, $content['SESSION_USERID'] ); WriteConfigValue( "ViewEnableDetailPopups", false, $content['SESSION_USERID'] ); diff --git a/src/index.php b/src/index.php index e623a5b..d182491 100644 --- a/src/index.php +++ b/src/index.php @@ -332,6 +332,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // --- Obtain characters limits first! $myMsgCharLimit = GetConfigSetting("ViewMessageCharacterLimit", 80, CFGLEVEL_USER); $myStrCharLimit = GetConfigSetting("ViewStringCharacterLimit", 30, CFGLEVEL_USER); + $ViewColoredCells = GetConfigSetting("ViewColoredCells", 0, CFGLEVEL_USER); // --- //Loop through the messages! @@ -370,10 +371,11 @@ if ( isset($content['Sources'][$currentSourceID]) ) // --- // --- Set CSS Class + $szCssAppend = ($ViewColoredCells == 1 ? ((isset($logArray[SYSLOG_SEVERITY]) && strlen($logArray[SYSLOG_SEVERITY]) > 0 ? "_" . $logArray[SYSLOG_SEVERITY] : "")) : ""); if ( $counter % 2 == 0 ) - $content['syslogmessages'][$counter]['cssclass'] = "line1" . (isset($logArray[SYSLOG_SEVERITY]) && strlen($logArray[SYSLOG_SEVERITY]) > 0 ? "_" . $logArray[SYSLOG_SEVERITY] : ""); + $content['syslogmessages'][$counter]['cssclass'] = "line1" . $szCssAppend; else - $content['syslogmessages'][$counter]['cssclass'] = "line2" . (isset($logArray[SYSLOG_SEVERITY]) && strlen($logArray[SYSLOG_SEVERITY]) > 0 ? "_" . $logArray[SYSLOG_SEVERITY] : ""); + $content['syslogmessages'][$counter]['cssclass'] = "line2" . $szCssAppend; // --- // --- Copy other needed properties diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index a1cc4df..c241f47 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -121,6 +121,7 @@ $content['LN_ADMIN_DEFAULTENCODING'] = "Default character encoding"; $content['LN_GEN_CONTEXTLINKS'] = "Enable Contextlinks (Question marks)"; $content['LN_GEN_DISABLEADMINUSERS'] = "Disable Adminpanel for normal users"; $content['LN_GEN_SESSION_MAX'] = "Load page in maximized mode"; +$content['LN_GEN_VIEWCOLOREDCELLS'] = "Colored Syslog messages based on Syslog Severity (Priority)"; // User Center $content['LN_USER_CENTER'] = "User Options"; diff --git a/src/templates/admin/admin_index.html b/src/templates/admin/admin_index.html index e70e226..557b8df 100644 --- a/src/templates/admin/admin_index.html +++ b/src/templates/admin/admin_index.html @@ -236,6 +236,15 @@ + + + {LN_GEN_VIEWCOLOREDCELLS} + + + + + + {LN_GEN_USETODAY}