diff options
author | Jannik Schönartz | 2016-11-23 23:06:34 +0100 |
---|---|---|
committer | Jannik Schönartz | 2016-11-23 23:06:34 +0100 |
commit | 8624f6747a8ce484a3cdc52ddc99793dc93fdf31 (patch) | |
tree | 12878084ada1bd7e75ca90f996435b2d2922ba9f /modules-available/locationinfo | |
parent | frontend: fixed typo (diff) | |
download | slx-admin-8624f6747a8ce484a3cdc52ddc99793dc93fdf31.tar.gz slx-admin-8624f6747a8ce484a3cdc52ddc99793dc93fdf31.tar.xz slx-admin-8624f6747a8ce484a3cdc52ddc99793dc93fdf31.zip |
Added a random generator for calendar stuff
Diffstat (limited to 'modules-available/locationinfo')
-rw-r--r-- | modules-available/locationinfo/api.inc.php | 37 | ||||
-rw-r--r-- | modules-available/locationinfo/page.inc.php | 1 |
2 files changed, 37 insertions, 1 deletions
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) { diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index f946bee8..da30ada9 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -231,7 +231,6 @@ class Page_LocationInfo extends Page $pc['x'] = $position['gridRow']; $pc['y'] = $position['gridCol']; - $data[] = $pc; } |