From 8624f6747a8ce484a3cdc52ddc99793dc93fdf31 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Wed, 23 Nov 2016 14:06:34 -0800 Subject: Added a random generator for calendar stuff --- modules-available/locationinfo/api.inc.php | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'modules-available/locationinfo/api.inc.php') diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 464ca2df..a4385084 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -18,7 +18,44 @@ function HandleParameters() { } elseif ($getAction == "config") { $getRoomID = Request::get('id', 0, 'int'); getConfig($getRoomID); + } elseif ($getAction == "calendar") { + $getRoomID = Request::get('id', 0, 'int'); + getCalendar($getRoomID); + } +} + +function randomCalendarGenerator() { + $randNum = rand(3, 7); + + $result = array(); + + for ($i = 0; $i < $randNum; $i++) { + $c = array(); + $c['title'] = getRandomWord(); + + $randH = rand(8, 16); + $rand2 = $randH + 2; + $date = getdate(); + $mday = $date['mday'] + $i; + $todays = $date['year'] . "-" . $date['month'] . "-" . $mday . " " . $randH . ":00:00"; + $c['start'] = $todays; + $todaye = $date['year'] . "-" . $date['month'] . "-" . $mday . " " . $rand2 . ":00:00"; + $c['end'] = $todaye; + $result[] = $c; } + + echo json_encode($result); +} + +function getRandomWord($len = 10) { + $word = array_merge(range('a', 'z'), range('A', 'Z')); + shuffle($word); + return substr(implode($word), 0, $len); +} + +function getCalendar($getRoomID) { + // TODO GET AND RETURN THE ACTUAL calendar + randomCalendarGenerator(); } function getConfig($locationID) { -- cgit v1.2.3-55-g7522