diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a1fd6d75..2f28cdf12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow. ### Upgrading -Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's four database changes (4.1.1 to 4.1.5) in the same pass. They add a column to RMM providers for the asset type each kind of device comes in as, three to rack items for devices side by side in a holder, the tables for phone systems, and two columns for network platforms, and change nothing that is there. Nothing else is required. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's five database changes (4.1.1 to 4.1.6) in the same pass. They add a column to RMM providers for the asset type each kind of device comes in as, three to rack items for devices side by side in a holder, the tables for phone systems, and two columns and a table for network platforms and their networks, and change nothing that is there. Nothing else is required. ### New Features & Updates @@ -24,6 +24,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Phone Systems: Yealink and Polycom desk phones report themselves as they start up and register - the Setup window has the lines for each - and become Phone assets of their domain's client, named after their extension, with their make, model, firmware, IP and MAC address. A client's asset that already has the phone's MAC address is used instead. The asset keeps up with new firmware and IP addresses, except for fields changed in ITFlow, and has a card saying whether the phone is registered and its line. The Domains page counts each domain's phones. - Screen pops: pick your extension under My desk phone in Your account > Preferences, and calls on your desk phone pop up at the bottom right of every page as they ring - the contact and their client, or the caller's name and number, with their open tickets and New Ticket (Quick Ticket, with the client and contact picked). Answered, it counts your talk time; ended, Add to Ticket puts the call on a ticket once its record is in, with the ticket you made for it picked. It comes from the phones, through the same Setup lines. - Network Platforms: Admin > Network Platforms brings in your clients' UniFi gateways, switches and access points as assets - from a controller you host, signed in to with a local view-only admin; from a UniFi console, with an API key made in UniFi Network; or from every console on your UI account through UniFi's Site Manager, with nothing to open up on the clients' networks. Link each site to its client and its devices come in, matched to the assets you have by MAC address, serial number or name, with their model, firmware, IP and MAC address kept up to date. An asset shows whether the device is online, how long it has been up, its public IP and whether a firmware update is waiting. It uses the same sync as RMM Providers, and its devices don't count as managed devices on recurring invoices. The password or API key is kept encrypted with this install's own key. +- Network Platforms: a linked site's networks and VLANs come in as its client's networks - matched to the one with the same subnet, or made - with their name, type, VLAN, subnet, gateway, DNS servers and DHCP range. Each detail follows UniFi until you change it in ITFlow, and the network's page has a card for the platform. WAN connections, site-to-site VPNs and VLANs with no subnet stay out. A network deleted in ITFlow isn't made again until Bring back on its site's row. ### Bug Fixes @@ -65,6 +66,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - `functions/rmm_unifi.php` has the three UniFi kinds: `unifi` signs in to a classic controller (`/api/login`, the `unifises` and `csrf_token` cookies) or a UniFi OS console (`/api/auth/login`, the `TOKEN` cookie and `X-CSRF-Token`, under `/proxy/network`), and signs in again once on a 401; `unifi_os` reads the Network Integration API (`X-API-KEY`, `/proxy/network/integration/v1` or `/integration/v1`, offset paging); `unifi_cloud` lists Site Manager's hosts and reads each console's integration API through `/v1/connector/consoles/{id}/proxy/network/integration/v1`, leaving out self-hosted controllers and naming the consoles it can't reach. `UNIFI_SITE_MANAGER_URL` can be defined in `config.php` to point it elsewhere for testing. A device's `remote_id` is its MAC address. - A kind with `seal` keeps `api_key` and `api_secret` as `enc1:` AES-256-GCM, keyed from `backupEncryptionKey()`; `rmmSecret($provider, $field)` reads them and `rmmSecretSeal()` writes them. `rmmHttp()` takes `insecure` and `cookies` options and returns the response headers and cookies. Kinds' `fields` can be `switch`, `text`, `url` or `secret` (with `spaces` for a password), and a kind can have `default_name`, `device_kinds` and `attention`. - `rmmAssetMatch()` matches by MAC address first, against `asset_interfaces` normalized by `rmmMac()`, then serial and name; `rmmAssetWrite()` writes `ip` and `mac` to the primary interface. `recurringSeatManagedSql(0)`, the managed-device seat options and `recurringSeatManagedLineCount()` count `rmm`-family providers only, and so does `rmmClientSummary()`. `rmmClientSuggestions()` also tries a site's name without a trailing `(console name)`. +- Database 4.1.6: `rmm_networks` - one network of a platform's site and the ITFlow network it is (0 once deleted there, so it isn't made again), with `rmm_network_synced` holding what the sync last wrote to each detail. Re-runnable. `functions/rmm_network.php` has `rmmNetworksSync()`, called by `rmmSync()` after each linked client's devices for a kind with a `networks` function, `rmmNetworkSave()` (match by `network` CIDR among the client's unarchived networks, or insert), `rmmNetworkFollow()` (the follow rule, with the two DNS columns kept together), `rmmNetworksForget()` (from `rmmForgetClientDevices()`), `rmmNetworksDeleted()` (from `networkDelete()`) and `rmmNetworksFor()` for the network page. A list with no networks marks none gone. +- `rmmUnifiNetworks($provider, $site)` reads a classic controller's `rest/networkconf` (purposes `corporate`, `guest` and `remote-user-vpn` with an `ip_subnet`) or the Network Integration API's `sites/{id}/networks` and each one's details (`GATEWAY` or `SWITCH` managed, with `ipv4Configuration`); a 404 on the list is a version without it, not an error. `rmmUnifiSiteWhere()` gives a Site Manager site's console and id. ## [26.12] diff --git a/admin/database_updates/4.1.6.php b/admin/database_updates/4.1.6.php new file mode 100644 index 000000000..fd6ece6ad --- /dev/null +++ b/admin/database_updates/4.1.6.php @@ -0,0 +1,36 @@ + 0"))[0]); mysqli_query($mysqli, "DELETE FROM rmm_devices WHERE rmm_device_provider_id = $provider_id"); + if (rmmNetworksReady()) { + mysqli_query($mysqli, "DELETE FROM rmm_networks WHERE rmm_network_provider_id = $provider_id"); + } if (rmmAlertsReady()) { mysqli_query($mysqli, "DELETE FROM rmm_alerts WHERE rmm_alert_provider_id = $provider_id"); } @@ -280,10 +283,16 @@ if (isset($_GET['rmm_bring_back'])) { $rmm_client_id = intval($rmm_client['rmm_client_id']); mysqli_query($mysqli, "DELETE FROM rmm_devices WHERE rmm_device_rmm_client_id = $rmm_client_id AND rmm_device_asset_id = 0"); $brought = mysqli_affected_rows($mysqli); + $brought_networks = 0; + if (rmmNetworksReady()) { + mysqli_query($mysqli, "DELETE FROM rmm_networks WHERE rmm_network_rmm_client_id = $rmm_client_id AND rmm_network_network_id = 0"); + $brought_networks = mysqli_affected_rows($mysqli); + } set_time_limit(180); $sync = rmmSync(rmmProviderRow($rmm_client['rmm_client_provider_id']), $rmm_client_id, 150); $words = rmmFamilyWords(rmmFamily($rmm_client)); - logAudit($words['audit'], "Edit", "$session_name brought back $brought deleted devices of " . escapeSql(rmmProviderName($rmm_client) . " {$words['client']} {$rmm_client['rmm_client_name']}"), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id'])); + $brought_words = implode(' and ', array_filter([$brought || !$brought_networks ? "$brought deleted device" . ($brought === 1 ? '' : 's') : '', $brought_networks ? "$brought_networks deleted network" . ($brought_networks === 1 ? '' : 's') : ''])); + logAudit($words['audit'], "Edit", "$session_name brought back $brought_words of " . escapeSql(rmmProviderName($rmm_client) . " {$words['client']} {$rmm_client['rmm_client_name']}"), intval($rmm_client['rmm_client_client_id']), intval($rmm_client['rmm_client_provider_id'])); flashAlert('' . escapeHtml($rmm_client['rmm_client_name']) . ' - ' . escapeHtml($sync['note']), $sync['ok'] ? 'success' : 'warning'); redirect('rmm_clients.php?provider_id=' . intval($rmm_client['rmm_client_provider_id'])); diff --git a/admin/rmm_clients.php b/admin/rmm_clients.php index 5cacd5869..0d54e6368 100644 --- a/admin/rmm_clients.php +++ b/admin/rmm_clients.php @@ -67,7 +67,9 @@ if (!isset($sortable_columns[$sort])) { $sort = 'rmm_client_name'; } -$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS rmm_clients.*, client_name, client_abbreviation, client_archived_at, +// A network platform's networks deleted in ITFlow are brought back with its devices +$networks_deleted_sql = rmmNetworksReady() ? "(SELECT COUNT(*) FROM rmm_networks WHERE rmm_network_rmm_client_id = rmm_clients.rmm_client_id AND rmm_network_removed_at IS NULL AND rmm_network_network_id = 0)" : '0'; +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS rmm_clients.*, client_name, client_abbreviation, client_archived_at, $networks_deleted_sql AS networks_deleted, (SELECT COUNT(*) FROM rmm_devices WHERE rmm_device_rmm_client_id = rmm_clients.rmm_client_id AND rmm_device_removed_at IS NULL AND rmm_device_asset_id > 0) AS assets_in, (SELECT COUNT(*) FROM rmm_devices WHERE rmm_device_rmm_client_id = rmm_clients.rmm_client_id AND rmm_device_removed_at IS NULL AND rmm_device_asset_id = 0) AS assets_deleted, (SELECT COUNT(*) FROM rmm_devices WHERE rmm_device_rmm_client_id = rmm_clients.rmm_client_id AND rmm_device_removed_at IS NULL AND rmm_device_status = 'overdue') AS devices_overdue @@ -191,6 +193,8 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO $suggested = $suggestions[$rmm_client_id] ?? 0; $sites = intval($row['rmm_client_sites']); $deleted = intval($row['assets_deleted']); + $networks_deleted = intval($row['networks_deleted']); + $deleted_words = implode(' and ', array_filter([$deleted ? "$deleted deleted device" . ($deleted === 1 ? '' : 's') : '', $networks_deleted ? "$networks_deleted deleted network" . ($networks_deleted === 1 ? '' : 's') : ''])); $overdue = intval($row['devices_overdue']); $link_url = "modals/rmm/rmm_client_link.php?id=$rmm_client_id"; ?> @@ -250,11 +254,11 @@ $devices_in = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FRO = $client_id ? 'Link to another client' : 'Link to a client' ?> - + - Bring back = $deleted ?> deleted + data-confirm-title="Bring back = $deleted_words ?>?" data-confirm-button="Bring back" + data-confirm-text="= !$networks_deleted ? 'Their assets were deleted in ITFlow. The sync matches them to assets that are there, or makes them again.' : (!$deleted ? 'They were deleted in ITFlow. The sync matches them to networks that are there, or makes them again.' : 'They were deleted in ITFlow. The sync matches them to the assets and networks that are there, or makes them again.') ?>"> + Bring back = $deleted + $networks_deleted ?> deleted diff --git a/agent/network.php b/agent/network.php index 500210ed5..567d50422 100644 --- a/agent/network.php +++ b/agent/network.php @@ -302,6 +302,29 @@ if (!$network || ($client_url && intval($network['network_client_id']) !== intva + +
= escapeHtml($platform_name) ?> stopped listing it = escapeHtml(timeAgo($platform_row['rmm_network_removed_at'])) ?> - it is kept here as it was.
+ +