diff options
| author | Simon Rettberg | 2025-07-07 13:37:19 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-07-07 13:37:19 +0200 |
| commit | 9a5106c288519b008e0dfe5e85371701af32c0f3 (patch) | |
| tree | fcfdc6efaf16d2ecefb2bc5822324e9324d6f29f /modules-available/locationinfo/page.inc.php | |
| parent | [locations] Copy permissions to children when deleting location (diff) | |
| download | slx-admin-9a5106c288519b008e0dfe5e85371701af32c0f3.tar.gz slx-admin-9a5106c288519b008e0dfe5e85371701af32c0f3.tar.xz slx-admin-9a5106c288519b008e0dfe5e85371701af32c0f3.zip | |
[locations] Cleanup Location class
There was a mess of functions which mostly, but not quite, did the same
things. Get rid of a couple of them and fix call sites to use
alternative ones that also fit the job.
While at it, add phpdoc and comments to the remaining functions, trying
to clarify what they were designed for.
Lastly, the return type of functions that retrieve a location id has
been changed from false|int to ?int (nullable types are just nicer).
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
| -rw-r--r-- | modules-available/locationinfo/page.inc.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index b5171200..fd9abb18 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -185,11 +185,7 @@ class Page_LocationInfo extends Page if ($changeServerRecursive) { // Recursive overwriting of serverid - $children = Location::getRecursiveFlat($locationid); - $array = array(); - foreach ($children as $loc) { - $array[] = $loc['locationid']; - } + $array = Location::getAllLocationIds($locationid); if (!empty($array)) { Database::exec("UPDATE locationinfo_locationconfig SET serverid = :serverid, lastcalendarupdate = IF(serverid <> :serverid, 0, lastcalendarupdate), lastchange = :now @@ -214,7 +210,7 @@ class Page_LocationInfo extends Page { $locationids = Request::post('locationids', Request::REQUIRED_EMPTY, 'string'); $locationids = explode(',', $locationids); - $all = array_map(function ($item) { return $item['locationid']; }, Location::queryLocations()); + $all = Location::getAllLocationIds(); $locationids = array_filter($locationids, function ($item) use ($all) { return in_array($item, $all); }); if (empty($locationids)) { Message::addError('main.parameter-empty', 'locationids'); @@ -617,7 +613,6 @@ class Page_LocationInfo extends Page $runmodes = RunMode::getForModule(Page::getModule(), true); } $panels = array(); - $locations = Location::getLocationsAssoc(); foreach ($res as $row) { if ($row['paneltype'] === 'URL') { $url = json_decode($row['panelconfig'], true)['url']; @@ -635,8 +630,8 @@ class Page_LocationInfo extends Page $row['runmode_disabled'] = $assignLocations !== true && !empty(array_diff($lids, $assignLocations)) ? 'disabled' : ''; // Locations - $locs = array_map(function ($id) use ($locations) { - return isset($locations[$id]) ? $locations[$id]['locationname'] : "<<deleted=$id>>"; + $locs = array_map(function ($id) { + return Location::getName($id) ?: "<<deleted=$id>>"; }, $lids); $row['locations'] = implode(', ', $locs); } @@ -1080,9 +1075,19 @@ class Page_LocationInfo extends Page die(Render::parse('frontend-default', $data, null, $config['language'])); } + if ($type === 'UPCOMING') { + $data += array( + 'uuid' => $uuid, + 'config' => json_encode($config), + 'language' => $config['language'], + ); + + die(Render::parse('frontend-kg2-upcoming', $data, null, $config['language'])); + } + if ($type === 'SUMMARY') { $locations = LocationInfo::getLocationsOr404($uuid, false); - $config['tree'] = Location::getRecursive($locations); + $config['tree'] = Location::getTree(...$locations); $data += array( 'uuid' => $uuid, 'config' => json_encode($config), |
