From 433a089fc113cba0d9662cb0d3634501f5f5eb28 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Sun, 5 Feb 2017 15:36:49 -0800 Subject: API added method for getting calendar info (unfiltered for now) with multiple id support --- modules-available/locationinfo/api.inc.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (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 421296b6..5c333271 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -20,13 +20,16 @@ function HandleParameters() { getConfig($getRoomID); } elseif ($getAction == "calendar") { $getRoomID = Request::get('id', 0, 'int'); - getCalendar($getRoomID); + echo getCalendar($getRoomID); } elseif ($getAction == "roomtree") { $roomIDS = Request::get('ids', 0, 'string'); getRoomTree($roomIDS); } elseif ($getAction == "pcstates") { $roomIDS = Request::get('ids', 0, 'string'); getPcStates($roomIDS); + } elseif ($getAction == "calendars") { + $roomIDS = Request::get('ids', 0, 'string'); + getCalendars($roomIDS); } } @@ -36,6 +39,19 @@ function getMultipleInformations($roomids) { return $filteredIdList; } +// TODO FILTER 2 weeks or some days only +function getCalendars($ids) { + $idList = getMultipleInformations($ids); + $calendars = array(); + + foreach ($idList as $id) { + $a['id'] = $id; + $a['calendar'] = json_decode(getCalendar($id), true); + $calendars[] = $a; + } + echo json_encode($calendars); +} + function getPcStates($ids) { $idList = getMultipleInformations($ids); @@ -156,9 +172,9 @@ function getCalendar($getRoomID) { $NOW = time(); if ($lastupdate == 0 || $NOW - $lastupdate > 900) { - echo updateCalendar($getRoomID, $serverid, $serverroomid); + return updateCalendar($getRoomID, $serverid, $serverroomid); } else { - echo $calendar; + return $calendar; } } -- cgit v1.2.3-55-g7522