From 55389af58db69917df1cd677fcf4de304ee02528 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 13 May 2022 10:45:30 +0200 Subject: [news] Fix news display: Load locations module before using it --- modules-available/news/api.inc.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'modules-available/news') diff --git a/modules-available/news/api.inc.php b/modules-available/news/api.inc.php index e8ef11d1..3b56c70d 100644 --- a/modules-available/news/api.inc.php +++ b/modules-available/news/api.inc.php @@ -4,12 +4,16 @@ header('Content-Type: application/xml; charset=utf-8'); $type = Request::any('type', 'news', 'string'); -$locationId = Request::any('location', 0, 'int'); -if ($locationId === 0) { - $locationId = Location::getFromIp($_SERVER['REMOTE_ADDR']); +if (Module::isAvailable('locations')) { + $locationId = Request::any('location', 0, 'int'); + if ($locationId === 0) { + $locationId = Location::getFromIp($_SERVER['REMOTE_ADDR']); + } + $locations = Location::getLocationRootChain($locationId); + $locations[] = 0; +} else { + $locations = [0]; } -$locations = Location::getLocationRootChain($locationId); -$locations[] = 0; // Fetch news from DB $res = Database::simpleQuery('SELECT title, locationid, content, dateline FROM vmchooser_pages @@ -24,7 +28,7 @@ $res = Database::simpleQuery('SELECT title, locationid, content, dateline FROM v // by closest to furthest $locations = array_flip($locations); foreach ($res as $row) { - $lid = $row['locationid']; + $lid = (int)$row['locationid']; if (is_array($locations[$lid])) continue; // Already have one $locations[$lid] = $row; -- cgit v1.2.3-55-g7522