From bbf1553f1d9b6c5233b9854142f8f93d076f600d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 9 Jun 2026 17:21:59 +0200 Subject: [locationinfo] Some more work on external device management --- .../locationinfo/lang/de/messages.json | 2 +- .../locationinfo/lang/en/messages.json | 2 +- modules-available/locationinfo/page.inc.php | 10 ++++----- .../templates/page-external-device-edit.html | 24 +++++++--------------- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/modules-available/locationinfo/lang/de/messages.json b/modules-available/locationinfo/lang/de/messages.json index 32f358ec..905d1269 100644 --- a/modules-available/locationinfo/lang/de/messages.json +++ b/modules-available/locationinfo/lang/de/messages.json @@ -5,7 +5,7 @@ "invalid-panel-type": "Ung\u00fcltiger Panel-Typ '{{0}}'", "invalid-server-id": "Ung\u00fcltige Server-ID '{{0}}'", "server-id-missing": "Server-ID fehlt", - "unregistered-devices-deleted": "{{count}} unregistriete Ger\u00e4te gel\u00f6scht.", + "unregistered-devices-deleted": "{{0}} unregistriete Ger\u00e4te gel\u00f6scht.", "invalid-device-id": "Ung\u00fcltige Ger\u00e4te-ID '{{0}}'", "device-deleted": "Gerät '{{0}}' erfolgreich gelöscht." } \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/messages.json b/modules-available/locationinfo/lang/en/messages.json index 1e323b26..037ce590 100644 --- a/modules-available/locationinfo/lang/en/messages.json +++ b/modules-available/locationinfo/lang/en/messages.json @@ -5,7 +5,7 @@ "invalid-panel-type": "Invalid panel type '{{0}}'", "invalid-server-id": "Invalid server id '{{0}}'", "server-id-missing": "Server id is missing", - "unregistered-devices-deleted": "{{count}} unregistered devices deleted.", + "unregistered-devices-deleted": "{{0}} unregistered devices deleted.", "invalid-device-id": "Invalid device id '{{0}}'", "device-deleted": "Device '{{0}}' successfully deleted." } \ No newline at end of file diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 13a5e181..fcca351a 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -641,7 +641,7 @@ class Page_LocationInfo extends Page { User::assertPermission('external-device.edit'); $count = Database::exec('DELETE FROM locationinfo_externaldevice WHERE isregistered = 0'); - Message::addSuccess('unregistered-devices-deleted', ['count' => $count]); + Message::addSuccess('unregistered-devices-deleted', $count); } private function showExternalDeviceEdit(): void @@ -655,14 +655,14 @@ class Page_LocationInfo extends Page Util::redirect('?do=locationinfo&show=external-devices'); } - $config = json_decode($device['configjson'], true); + $config = json_decode($device['configjson'] ?? '{}', true); if (!is_array($config)) { $config = []; } $device['reboot_hour'] = $config['reboot_hour'] ?? -1; $device['brightness_pct'] = $config['brightness_pct'] ?? 100; - $panels = Database::simpleQuery('SELECT paneluuid, panelname FROM locationinfo_panel ORDER BY panelname ASC'); + $panels = Database::queryAll('SELECT paneluuid, panelname FROM locationinfo_panel ORDER BY panelname ASC'); foreach ($panels as &$panel) { $panel['selected'] = ($panel['paneluuid'] === $device['paneluuid']) ? 'selected' : ''; } @@ -683,7 +683,6 @@ class Page_LocationInfo extends Page if ($paneluuid === '') { $paneluuid = null; } - $isregistered = Request::post('isregistered', 0, 'int'); $reboot_hour = Request::post('reboot_hour', -1, 'int'); $brightness_pct = Request::post('brightness_pct', 100, 'int'); @@ -695,12 +694,11 @@ class Page_LocationInfo extends Page $res = Database::exec('UPDATE locationinfo_externaldevice SET title = :title, paneluuid = :paneluuid, - isregistered = :isregistered, + isregistered = 1, configjson = :configjson WHERE deviceuuid = :deviceid', [ 'title' => $title, 'paneluuid' => $paneluuid, - 'isregistered' => $isregistered, 'configjson' => json_encode($config), 'deviceid' => $deviceid, ]); diff --git a/modules-available/locationinfo/templates/page-external-device-edit.html b/modules-available/locationinfo/templates/page-external-device-edit.html index 388bdafb..c3027221 100644 --- a/modules-available/locationinfo/templates/page-external-device-edit.html +++ b/modules-available/locationinfo/templates/page-external-device-edit.html @@ -2,7 +2,6 @@