diff options
Diffstat (limited to 'modules-available/locations/inc/openingtimes.inc.php')
-rw-r--r-- | modules-available/locations/inc/openingtimes.inc.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules-available/locations/inc/openingtimes.inc.php b/modules-available/locations/inc/openingtimes.inc.php new file mode 100644 index 00000000..3417a213 --- /dev/null +++ b/modules-available/locations/inc/openingtimes.inc.php @@ -0,0 +1,28 @@ +<?php + +class OpeningTimes +{ + + /** + * Get opening times for given location. + */ + public static function forLocation(int $locationId) + { + static $openingTimesList = false; + if ($openingTimesList === false) { + $openingTimesList = Database::queryKeyValueList("SELECT locationid, openingtime FROM location + WHERE openingtime IS NOT NULL"); + } + $chain = Location::getLocationRootChain($locationId); + $openingTimes = null; + foreach ($chain as $lid) { + if (isset($openingTimesList[$lid])) { + if (is_string($openingTimesList[$lid])) { + $openingTimesList[$lid] = json_decode($openingTimesList[$lid], true); + } + return $openingTimesList[$lid]; + } + } + return null; + } +}
\ No newline at end of file |