diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc92349a..6a1fd6d75 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 three database changes (4.1.1 to 4.1.4) 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, and the tables for phone systems, 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 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. ### New Features & Updates @@ -23,6 +23,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Phone Systems: as a call rings, desk phones show the contact and their client - Marla Whitfield - Ravenwood Dental - when ITFlow knows the number, and the carrier's name otherwise. - 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. ### Bug Fixes @@ -60,6 +61,10 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - `phoneWho($number, $domain_client_id)` matches a number with `smsContactsFor()` - a mobile before an office number many share - then clients' location phones; a number more than one client has is nobody's. On a client's domain only that client counts; on your own company's (`config_internal_client_id`) or one not linked, every client does. `phoneDomainLink()` matches a domain's calls again. `phoneCallToTicket()` adds the internal note, its talk time as `ticket_reply_time_worked` with the work start and end, and `add_ticket` takes `phone_call_id` (ticket source Phone). `phoneCleanup()` runs nightly: calls over 400 days old that aren't on a ticket go. Client delete and merge take the phone tables. - `api/phone/hook.php` takes desk phones' events through `phoneHookEvent()` - Yealink action URLs as GET (`e` = setup, registered, unregistered, failed, ringing, outgoing, answered or ended, with `mac`, `ip`, `model`, `fw`, `line`, `domain`, `number`, `name` and `call`; a variable the phone left unfilled counts as nothing) or Polycom telephony notifications posted as XML (`phoneHookPolycom()`), with the vendor, model and firmware from the User-Agent when the request doesn't say. `phoneDeviceSave()` keeps a phone by system and MAC in `phone_devices`, and `phoneDeviceAsset()` finds the client's asset by MAC (`asset_interfaces.interface_mac`, any separators) or makes a Phone asset with its interface and `extension` detail, then follows the phone the way RMM devices do: a field is written when empty or still what the phone said last. `phone_device_asset_id` -1 is an asset deleted in ITFlow, not made again. `phoneDomainLink()` runs it for the domain's phones. - Screen pops: `api/phone/hook.php` saves call events (ringing, outgoing, answered, ended, missed) with an outside number to `phone_events` for each agent whose `user_config_phone_line` (`ext@domain`, Your account > Preferences, `phoneLineChoices()`) the line is - `phoneEventSave()`, `phoneUsersForLine()`. `js/phone_pop.js`, loaded by `includes/footer.php` on pages in `agent/` for agents with a line, asks `agent/ajax.php?phone_pop` every 3 seconds while the page is visible; `phonePopCalls()` groups the agent's events of the last 4 hours by the phone's call id (else number and line) and answers at most two calls - ringing for 90 seconds after the last event, answered until ended, ended for 10 minutes - with the contact, client and open tickets for clients the agent can reach and, ended, the `phone_calls` record matched by number, line and time. The handler closes the session before working. New Ticket opens `ticket_quick.php` with `contact_id` and `phone_call` (the call key: timer off), or `ticket_add.php` with `phone_pop_call`; `add_ticket` remembers the ticket per key in the session (`phonePopTicketMade()`) and sets ticket source Phone, and `phone_call_ticket.php` takes `ticket_id` to pick it. phone_events still go after 2 days. +- Database 4.1.5: `rmm_providers.rmm_provider_insecure` (accept a self-signed certificate) and `rmm_devices.rmm_device_mac` (12 lowercase hex digits, indexed). Re-runnable. A network platform is an `rmm_providers` row whose kind's `family` is `network`; its sites are `rmm_clients` rows and its devices `rmm_devices` rows, so the follow rule, gone-hold, Bring back and asset types work unchanged. `rmmFamily()`, `rmmFamilyWords()` and `rmmFamilyProviders()` in `functions/rmm.php` split the two; `admin/network_platforms.php` sets `$rmm_family = 'network'` and includes `admin/rmm_providers.php`. +- `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)`. ## [26.12] diff --git a/admin/database_updates/4.1.5.php b/admin/database_updates/4.1.5.php new file mode 100644 index 000000000..c1a446194 --- /dev/null +++ b/admin/database_updates/4.1.5.php @@ -0,0 +1,39 @@ + Network Platforms, functions/rmm_unifi.php). They + * use the RMM providers' tables: a platform is an rmm_providers row of a network kind, its + * sites are rmm_clients rows, and its switches, access points and gateways rmm_devices rows. + * + * rmm_providers.rmm_provider_insecure 1 to accept the certificate a self-hosted controller + * made for itself - 0, checked as usual, for the rest + * rmm_devices.rmm_device_mac the device's MAC address, 12 lower-case hex digits - + * '' when its kind doesn't say + * + * Re-runnable: it only adds what isn't there. + */ + +defined('FROM_DB_UPDATER') || die("Direct file access is not allowed"); + + $itflow_has = function ($table, $what, $name) use ($mysqli) { + $from = $what === 'column' ? 'COLUMNS' : 'STATISTICS'; + $field = $what === 'column' ? 'COLUMN_NAME' : 'INDEX_NAME'; + $result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.$from + WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND $field = '$name' LIMIT 1"); + return $result && mysqli_num_rows($result) > 0; + }; + + if (!$itflow_has('rmm_providers', 'column', 'rmm_provider_insecure')) { + mysqli_query($mysqli, "ALTER TABLE `rmm_providers` ADD `rmm_provider_insecure` tinyint(1) NOT NULL DEFAULT 0 AFTER `rmm_provider_api_secret`"); + } + if (!$itflow_has('rmm_devices', 'column', 'rmm_device_mac')) { + mysqli_query($mysqli, "ALTER TABLE `rmm_devices` ADD `rmm_device_mac` varchar(12) NOT NULL DEFAULT '' AFTER `rmm_device_remote_id`"); + } + if (!$itflow_has('rmm_devices', 'key', 'rmm_device_mac')) { + mysqli_query($mysqli, "ALTER TABLE `rmm_devices` ADD KEY `rmm_device_mac` (`rmm_device_mac`)"); + } + + unset($itflow_has); diff --git a/admin/includes/side_nav.php b/admin/includes/side_nav.php index 7424a30ce..90c2f2c8b 100644 --- a/admin/includes/side_nav.php +++ b/admin/includes/side_nav.php @@ -139,13 +139,23 @@ = adminNavGroupItemHtml('text') ?> +
RMM Providers
Network Platforms
+ +Its = number_format($devices) ?> device= $devices === 1 ? '' : 's' ?> in = escapeHtml($name) ?> come in as this client's assets - matched to the ones it has by serial number or name, made where there are none. +
Its = number_format($devices) ?> device= $devices === 1 ? '' : 's' ?> in = escapeHtml($name) ?> come in as this client's assets - matched to the ones it has by = rmmFamily($row) === 'network' ? 'MAC address' : 'serial number' ?> or name, made where there are none. Linked to another client, they come in there - the assets already brought in for = escapeHtml((string) $row['client_name']) ?> stay, no longer kept up.
diff --git a/admin/modals/rmm/rmm_provider_edit.php b/admin/modals/rmm/rmm_provider_edit.php index c83776843..af9eb7987 100644 --- a/admin/modals/rmm/rmm_provider_edit.php +++ b/admin/modals/rmm/rmm_provider_edit.php @@ -8,7 +8,8 @@ * level picked, in a category. Desktops, laptops, servers and virtual machines each come in as * the asset type picked for them (rmmProviderAssetTypes()). Save asks first (check_rmm_provider, admin/post/rmm.php): what * is wrong shows beside each field and the window stays open; once all is right it saves, and - * tries the connection. + * tries the connection. A network platform's window (family=network, or one being edited) + * offers the network kinds - UniFi - in its words. */ require_once '../../includes/modal_header.php'; @@ -16,7 +17,7 @@ require_once '../../includes/modal_header.php'; $provider_id = intval($_GET['id'] ?? 0); $row = $provider_id ? rmmProviderRow($provider_id) : null; if ($provider_id && !$row) { - echo json_encode(['error' => 'That RMM provider no longer exists.']); + echo json_encode(['error' => 'That provider or platform no longer exists.']); exit; } if ($row && !rmmKind($row)) { @@ -24,13 +25,15 @@ if ($row && !rmmKind($row)) { exit; } -$kinds = rmmProviderKinds(); +$family = $row ? rmmFamily($row) : (($_GET['family'] ?? '') === 'network' && rmmNetworkReady() ? 'network' : 'rmm'); +$words = rmmFamilyWords($family); +$kinds = rmmProviderKinds($family); $kind_key = $row ? (string) $row['rmm_provider_kind'] : (string) array_key_first($kinds); $kind = $kinds[$kind_key]; // What the window's script needs of each kind - its name, to follow the kind picked, and whether it has alerts $kinds_js = array_map(function ($info) { - return ['name' => $info['name'], 'alerts' => isset($info['alerts'], $info['alert']), 'alertsHelp' => (string) ($info['alerts_help'] ?? '')]; + return ['name' => $info['default_name'] ?? $info['name'], 'alerts' => isset($info['alerts'], $info['alert']), 'alertsHelp' => (string) ($info['alerts_help'] ?? '')]; }, $kinds); // Alerts open tickets - once the 3.6.8 database update is in, with ticketing on @@ -47,12 +50,13 @@ ob_start(); ?>