From b75645cc1b0d088d895bbe7561c5a86b84d4a0bb Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 16 Apr 2019 17:55:50 +0200 Subject: [roomplanner] Don't generate roomplan if pointless If a UUID for a machine is passed that maps into a location by its IP address, but doesn't have a position in it, don't render a SVG for that location, unless the locationid is explicitly specified too. --- modules-available/roomplanner/inc/pvsgenerator.inc.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules-available/roomplanner/inc/pvsgenerator.inc.php b/modules-available/roomplanner/inc/pvsgenerator.inc.php index 6bc8ebee..e05ee1f1 100644 --- a/modules-available/roomplanner/inc/pvsgenerator.inc.php +++ b/modules-available/roomplanner/inc/pvsgenerator.inc.php @@ -159,11 +159,13 @@ class PvsGenerator public static function generateSvg($locationId = false, $highlightUuid = false, $rotate = 0) { if ($locationId === false) { - $locationId = Database::queryFirst('SELECT locationid FROM machine WHERE machineuuid = :uuid', + $locationId = Database::queryFirst('SELECT fixedlocationid FROM machine + WHERE machineuuid = :uuid AND Length(position) > 5', ['uuid' => $highlightUuid]); - if ($locationId !== false) { - $locationId = $locationId['locationid']; - } + // Not found or not placed in room plan -- bail out + if ($locationId === false || $locationId['fixedlocationid'] === null) + return false; + $locationId = $locationId['fixedlocationid']; } $machines = self::getMachines($locationId); if (empty($machines)) -- cgit v1.2.3-55-g7522