summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/api.inc.php
diff options
context:
space:
mode:
authorJannik Schönartz2016-11-23 23:06:34 +0100
committerJannik Schönartz2016-11-23 23:06:34 +0100
commit8624f6747a8ce484a3cdc52ddc99793dc93fdf31 (patch)
tree12878084ada1bd7e75ca90f996435b2d2922ba9f /modules-available/locationinfo/api.inc.php
parentfrontend: fixed typo (diff)
downloadslx-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/api.inc.php')
-rw-r--r--modules-available/locationinfo/api.inc.php37
1 files changed, 37 insertions, 0 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) {