From 370b80a67b006eaa6391d8eebdd1c611ab063373 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 27 Nov 2026 13:49:31 -0500 Subject: [PATCH] Logs: the log settings are a Settings tab under Admin > Logs beside Audit Logs, Sign-ins and App Logs instead of a page in the Settings menu and overview, still found by Find a setting and the top bar search as Logs > Settings; settings pages can be put under an admin menu entry with an under key; references to Admin > Settings > Logs updated; 26.12.2 changelog entries --- CHANGELOG.md | 2 ++ admin/ai_usage.php | 2 +- admin/includes/side_nav.php | 5 ++++- admin/post/settings_logs.php | 2 +- admin/settings.php | 6 ++---- admin/settings_logs.php | 2 +- cron/nightly_tasks.php | 2 +- functions/app_log.php | 2 +- functions/log_forward.php | 4 ++-- functions/settings.php | 31 ++++++++++++++++++++++++------- 10 files changed, 39 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f47e8eda..28826d632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ If you manage other ITFlow installs, the manager and its instances can be update - Managed Instances: how much each instance is used. Its History card has a Usage part - tickets opened and resolved and those that came in by email, replies and notes by its agents, how many agents signed in each day and over the last 30 days, client portal sign-ins, invoices made and payments recorded, email sent and failed, and API calls with the keys that made the most of them - each day as the instance counts it, by its own date. The list has a Last 30 days column - tickets opened, how many of its agents signed in and when one last did, and API calls - and sorting by it puts the ones hardly used first. Only counts are sent, never what any of them say, and Managed By on the instance says so. - Managed Instances: an instance's page has an Agents card - who holds its seats, with each agent's name, email, role, whether they sign in with MFA and when they last signed in, then the invites waiting and the day each runs out. API accounts are marked. The support user takes no seat and isn't listed. Managed By, on the instance, lists this among what it tells its manager. - Managed Instances: errors logged on an instance now say which categories they were logged under, in its health line and under Errors today, where the count and each category sign you in to it as support on its App Logs, showing just those errors. Only how many there are under each category is sent - never what an error says, which can hold a client's email address or a ticket's subject. +- Logs: the log settings - how long the audit log and app logs are kept, and sending them on to a syslog server or SIEM - are now a **Settings** tab under Admin > Logs, beside Audit Logs, Sign-ins and App Logs, instead of a page of their own in the Settings menu. Find a setting still finds them. - Payment reminders: a client with more than one late invoice gets one reminder for all of them, instead of one for each invoice on its own dates. It goes on the days of their oldest late invoice, on your reminder schedule, and lists everything they owe - each invoice with its link, the late ones marked, and the total - with the statement PDF attached when reminder emails attach PDFs. Texts send one reminder the same way. An invoice that goes late in between is in the next one, and an invoice's page shows when that is. A client with just one late invoice gets that invoice's own reminder, as before, and reminders before and on the due date are still one per invoice. When the monthly statement falls on the same day, the reminder goes in its place. ### Bug Fixes @@ -47,6 +48,7 @@ If you manage other ITFlow installs, the manager and its instances can be update - Database 4.2.0: `managed_instance_stats` gets a column for each of `MANAGED_USAGE_FIGURES`, `_api_keys` (JSON) and `_agents_30d`, all NULL for a day nothing was reported. Re-runnable. `managedStatsRecord()` writes each of the instance's days onto the row of the same date, when it is there and within three days, and `_agents_30d` onto today's; `managedUsageReady()` guards it. `managedInstanceHistory()` adds each day's figures, `usage` (their totals, or null), `api_keys` and `agents_30d`, and the weekly view adds the figures up - `agent_signins` taking the week's highest day. - `admin/managed_instances.php` reads each instance's last 30 days in one query, and sorts by tickets opened in them as `usage_tickets` - a sort key keeps to letters and underscores, as `filter_header.php` strips anything else. The Health column wraps, so the table fits. - Payment reminders: `cron/nightly_tasks.php` gathers each client's late invoices and reminds them once, when `billingReminderOnDay()` is true for the oldest one's days late - `billingOverdueEmail()` from `billingStatement()` with two or more late, and the invoice's own reminder with one. Each invoice in it gets a `Reminder emailed` history line, so the once-a-day check still holds. `billingReminderNext()` returns `with_others` and counts late days from `billingReminderClientOldestDue()`. `smsClientOverdueNotify()` sends the combined text, and `billingStatementLines()` builds the invoice rows for statements and the combined reminder. +- Settings pages: a `settingsPages()` entry with `'under' => ''` is a tab of that `adminNavGroups()` entry - `settingsPageStart()` draws the group's tabs above it with no link back to Settings, and it isn't in the Settings menu or overview. Find a setting gives where it is as that entry - "Logs › Settings › ..." - and the top bar search the same. Log Settings (`settings_logs.php`) is the first, under `logs`. - 2FA keys: database 4.2.1 makes `credentials.credential_otp_secret` `varchar(500)`. A key is stored as `CREDENTIAL_OTP_VAULT` (`vault:`) and then what `encryptCredentialEntry()` gives - store one with `credentialOtpEncrypt()` (false when the vault isn't open) or `apiCredentialOtpEncrypt()`, and read it with `credentialOtpSecret()` or `apiCredentialOtpSecret()`. A value without the prefix was saved before and is read as it is. `credentialOtpVaultStored()`, from `includes/check_login.php`, encrypts those once a session, 500 at a time. It runs only when `vaultSessionOpens()` (the session's master key decrypts to 16 characters), checks that each decrypts back, and writes it only over the value it read. `credentialOtpSeed()` refuses a seed over 256 characters, so an encrypted one always fits. Pre-2.9.0 credential shares, which read the key live, show no code for an encrypted key. ## [26.12.1] diff --git a/admin/ai_usage.php b/admin/ai_usage.php index fa798d403..dc711fab8 100644 --- a/admin/ai_usage.php +++ b/admin/ai_usage.php @@ -8,7 +8,7 @@ * it worked - why not, when it didn't. Totals for what is shown sit above. * Searched, and filtered by date, provider, model, feature and who; views for * the failed ones, the ones secrets were taken out of, and tests. Kept as long - * as the audit log is (Admin > Settings > Logs). + * as the audit log is (Admin > Logs > Settings). */ // Default Column Sortby Filter diff --git a/admin/includes/side_nav.php b/admin/includes/side_nav.php index 90c2f2c8b..a2b653117 100644 --- a/admin/includes/side_nav.php +++ b/admin/includes/side_nav.php @@ -247,7 +247,10 @@ diff --git a/admin/post/settings_logs.php b/admin/post/settings_logs.php index 28ace2579..f151e6dce 100644 --- a/admin/post/settings_logs.php +++ b/admin/post/settings_logs.php @@ -1,7 +1,7 @@ Settings > Logs: how long each log is + * ITFlow - POST handler for Admin > Logs > Settings: how long each log is * kept, and sending entries on to a syslog server or SIEM. Save and send a * test saves first, then sends one test message with what was saved * (logForwardTest(), functions/log_forward.php). What changed is in the audit diff --git a/admin/settings.php b/admin/settings.php index 5381bb5f8..6d73a7ff1 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -13,8 +13,6 @@ $company = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT company_name, compan FROM companies WHERE company_id = 1")) ?: []; $localization = settingsLocalizationArrays(); $themes = settingsThemes(); -$retention = appLogRetention(); -$forward = logForwardSettings(); $on_off = function ($on) { return $on ? 'on' : 'off'; }; @@ -58,7 +56,6 @@ $summaries = [ 'client_portal' => 'Two-step sign-in ' . ($config_client_portal_require_mfa ? 'required' : 'optional'), 'identity' => 'Microsoft Entra ' . ($config_azure_client_id ? 'set up' : 'not set up'), 'module' => $modules_on ? escapeHtml(implode(', ', $modules_on)) : 'None in use', - 'logs' => 'Audit log ' . ($retention['audit'] ? 'kept ' . $days($retention['audit']) : 'kept forever') . ' · ' . ($forward['enabled'] ? 'sent to ' . escapeHtml($forward['host']) : 'not sent on'), 'telemetry' => $config_telemetry ? 'Nightly report on' : 'Off', ]; @@ -139,7 +136,8 @@ $groups = settingsGroups();

$page) { - if ($page['group'] !== $group_key) { + // A tab of another menu entry (Log Settings, under Logs) is found by Find a setting, not here + if ($page['group'] !== $group_key || !empty($page['under'])) { continue; } $available = settingsPageAvailable($page); ?> diff --git a/admin/settings_logs.php b/admin/settings_logs.php index 312ac30bd..3485de2fd 100644 --- a/admin/settings_logs.php +++ b/admin/settings_logs.php @@ -1,7 +1,7 @@ Settings > Logs - how long the audit log (with API key use) and + * Admin > Logs > Settings - how long the audit log (with API key use) and * the app logs are kept, each its own number of days or forever, and sending * their entries on to a syslog server or SIEM as they are written * (functions/log_forward.php). Saved by edit_log_settings, or diff --git a/cron/nightly_tasks.php b/cron/nightly_tasks.php index efc825ad9..4254f2a95 100644 --- a/cron/nightly_tasks.php +++ b/cron/nightly_tasks.php @@ -193,7 +193,7 @@ mysqli_query($mysqli, "DELETE FROM remember_tokens WHERE remember_token_created_ // delete the archive it was supposed to replace. backupRunRetention($mysqli); -// Cleanup old logs - each kept for its own number of days, 0 for keep forever (Admin > Settings > Logs, functions/app_log.php) +// Cleanup old logs - each kept for its own number of days, 0 for keep forever (Admin > Logs > Settings, functions/app_log.php) $log_retention = appLogRetention(); // The audit log, and API key and AI use with it diff --git a/functions/app_log.php b/functions/app_log.php index 983aeeaea..afd8169ab 100644 --- a/functions/app_log.php +++ b/functions/app_log.php @@ -8,7 +8,7 @@ * by level, searched and filtered by category and date, the same way they * are exported and cleared (appLogFiltersSql()), each with a quick look * (admin/modals/app_log/app_log.php). Nightly keeps them for their own number - * of days (Admin > Settings > Logs, appLogRetention()). + * of days (Admin > Logs > Settings, appLogRetention()). */ /** The levels, worst first - each with its label, the word for one, icon and tone. */ diff --git a/functions/log_forward.php b/functions/log_forward.php index a848306bd..714d104ba 100644 --- a/functions/log_forward.php +++ b/functions/log_forward.php @@ -2,7 +2,7 @@ /* * ITFlow - sending log entries on to a syslog server or SIEM as they are - * written (Admin > Settings > Logs). Each audit log entry - from logAudit() + * written (Admin > Logs > Settings). Each audit log entry - from logAudit() * and the few places that write to logs themselves - and each app log entry * at or above the level picked (logApp()) goes out as an RFC 5424 syslog * message, over UDP, TCP or TLS, with the entry as JSON, CEF or plain text. @@ -576,7 +576,7 @@ function logForwardAppMessage(array $row, $format) { */ function logForwardTest(array $settings, $by = '') { $now = date('Y-m-d H:i:s'); - $text = 'Test message from ITFlow' . ($by !== '' ? " - sent by $by" : '') . ' from Admin > Settings > Logs'; + $text = 'Test message from ITFlow' . ($by !== '' ? " - sent by $by" : '') . ' from Admin > Logs > Settings'; if ($settings['format'] === 'cef') { $message = logForwardCefStart('test', 'Test message', 6) . logForwardCefExtensions(['rt' => time() * 1000, 'msg' => $text, 'dvchost' => logForwardHostname()]); } elseif ($settings['format'] === 'plain') { diff --git a/functions/settings.php b/functions/settings.php index 53663c9a0..548dfc60d 100644 --- a/functions/settings.php +++ b/functions/settings.php @@ -31,7 +31,9 @@ function settingsGroups() { /* * Every settings page - its group, title, icon, address, what it is for, and - * the module it belongs to (hidden from the menu while that is off). + * the module it belongs to (hidden from the menu while that is off). One with + * 'under' is a tab of that admin menu entry (adminNavGroups()) instead - not + * in the Settings menu or overview, but still found by Find a setting. */ function settingsPages() { return [ @@ -67,7 +69,7 @@ function settingsPages() { 'about' => 'Contacts signing in to the client portal with their Microsoft 365 account.'], 'module' => ['group' => 'system', 'title' => 'Modules', 'icon' => 'fa-cube', 'url' => 'settings_module.php', 'about' => 'The parts of ITFlow in use - IT documentation, ticketing, invoicing, the calendar, the Knowledge Base and the client portal, and the parts that come with them - and white-labelling.'], - 'logs' => ['group' => 'system', 'title' => 'Logs', 'icon' => 'fa-scroll', 'url' => 'settings_logs.php', + 'logs' => ['group' => 'system', 'title' => 'Log Settings', 'icon' => 'fa-scroll', 'url' => 'settings_logs.php', 'under' => 'logs', 'about' => 'How long the audit log and app logs are kept, and sending them on to a syslog server or SIEM.'], 'telemetry' => ['group' => 'system', 'title' => 'Telemetry', 'icon' => 'fa-satellite-dish', 'url' => 'settings_telemetry.php', 'about' => 'Whether ITFlow tells the ITFlow project, each night, how it is being used.'], @@ -138,6 +140,7 @@ function adminNavGroups() { ['file' => 'audit_logs.php', 'icon' => 'fa-history', 'label' => 'Audit Logs'], ['file' => 'sign_ins.php', 'icon' => 'fa-sign-in-alt', 'label' => 'Sign-ins'], ['file' => 'app_logs.php', 'icon' => 'fa-clipboard-list', 'label' => 'App Logs'], + ['file' => 'settings_logs.php', 'icon' => 'fa-sliders-h', 'label' => 'Settings'], ]], 'templates' => ['label' => 'Templates', 'icon' => 'fa-copy', 'pages' => array_values(array_filter([ $ticketing ? ['file' => 'ticket_templates.php', 'icon' => 'fa-life-ring', 'label' => 'Tickets', 'also' => ['ticket_template.php']] : null, @@ -451,8 +454,13 @@ function settingsFields() { function settingsSearchIndex() { $pages = settingsPages(); $index = []; + // A tab of another menu entry is where it is - "Logs", "Logs › Settings" - rather than under Settings + $under = function ($page) { + return empty($page['under']) ? '' : (adminNavGroups()[$page['under']]['label'] ?? ''); + }; foreach ($pages as $key => $page) { - $index[] = ['label' => $page['title'], 'where' => 'Settings', 'url' => $page['url'], 'icon' => $page['icon'], 'words' => strtolower($page['about']), 'page' => true]; + $index[] = ['label' => $page['title'], 'where' => $under($page) ?: 'Settings', 'url' => $page['url'], 'icon' => $page['icon'], 'words' => strtolower($page['about']), 'page' => true] + + ($under($page) ? ['under' => true] : []); } foreach (settingsFields() as $name => $field) { if (($field['search'] ?? true) === false || !isset($pages[$field['page']])) { @@ -460,7 +468,9 @@ function settingsSearchIndex() { } $page = $pages[$field['page']]; $url = $page['url'] . (isset($field['tab']) ? '?tab=' . $field['tab'] : '') . '#setting=' . $name; - $index[] = ['label' => $field['label'], 'where' => $page['title'] . ' › ' . $field['section'], 'url' => $url, 'icon' => $page['icon'], 'words' => strtolower($field['words'] ?? '')]; + $where = $under($page) ? $under($page) . ' › Settings' : $page['title']; + $index[] = ['label' => $field['label'], 'where' => $where . ' › ' . $field['section'], 'url' => $url, 'icon' => $page['icon'], 'words' => strtolower($field['words'] ?? '')] + + ($under($page) ? ['under' => true] : []); } return $index; } @@ -518,7 +528,8 @@ function settingsSearch($raw_query, $limit = 3) { }); $items = []; foreach (array_slice($scored, 0, $limit) as [, , $entry]) { - $items[] = ['title' => $entry['label'], 'subtitle' => $entry['where'] === 'Settings' ? 'Settings page' : 'Settings › ' . $entry['where'], 'url' => '/admin/' . $entry['url']]; + $subtitle = !empty($entry['under']) ? $entry['where'] : ($entry['where'] === 'Settings' ? 'Settings page' : 'Settings › ' . $entry['where']); + $items[] = ['title' => $entry['label'], 'subtitle' => $subtitle, 'url' => '/admin/' . $entry['url']]; } return $items; } @@ -540,11 +551,17 @@ function settingsPageStart($page_key, $actions_html = '') { $settings_kept = $_SESSION['settings_kept']; } unset($_SESSION['settings_kept']); - ob_start(); ?> + ob_start(); + // A tab of another menu entry - its tabs above it, as its other pages have them + if (!empty($page['under'])) { + echo adminNavGroupTabsHtml($page['under']); + } ?>
- Settings + + Settings +