summaryrefslogtreecommitdiffstats
path: root/modules-available/news
diff options
context:
space:
mode:
authorSimon Rettberg2022-05-13 10:45:30 +0200
committerSimon Rettberg2022-05-13 10:45:30 +0200
commit55389af58db69917df1cd677fcf4de304ee02528 (patch)
treef77b49ecf74edf9fc2e15ae012caf55b0068b4e4 /modules-available/news
parent[inc/Property] Types, remove unused functions (diff)
downloadslx-admin-55389af58db69917df1cd677fcf4de304ee02528.tar.gz
slx-admin-55389af58db69917df1cd677fcf4de304ee02528.tar.xz
slx-admin-55389af58db69917df1cd677fcf4de304ee02528.zip
[news] Fix news display: Load locations module before using it
Diffstat (limited to 'modules-available/news')
-rw-r--r--modules-available/news/api.inc.php16
1 files changed, 10 insertions, 6 deletions
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;