From a6daa4d10b14a08d5e0a8d127f5442984c511475 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 27 Apr 2015 18:06:36 +0200 Subject: [PATCH] Support dtstart/dtend parameters on free/busy query URLs --- plugins/libkolab/lib/kolab_storage.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php index e0a2d01f..6ece5b49 100644 --- a/plugins/libkolab/lib/kolab_storage.php +++ b/plugins/libkolab/lib/kolab_storage.php @@ -273,10 +273,32 @@ class kolab_storage /** * Compose an URL to query the free/busy status for the given user + * + * @param string Email address of the user to get free/busy data for + * @param object DateTime Start of the query range (optional) + * @param object DateTime End of the query range (optional) + * + * @return string Fully qualified URL to query free/busy data */ - public static function get_freebusy_url($email) + public static function get_freebusy_url($email, $start = null, $end = null) { - return self::get_freebusy_server() . '/' . $email . '.ifb'; + $query = ''; + $param = array(); + $utc = new \DateTimeZone('UTC'); + + if ($start instanceof \DateTime) { + $start->setTimezone($utc); + $param['dtstart'] = $start->format('Ymd\THis\Z'); + } + if ($end instanceof \DateTime) { + $end->setTimezone($utc); + $param['dtend'] = $end->format('Ymd\THis\Z'); + } + if (!empty($param)) { + $query = '?' . http_build_query($param); + } + + return self::get_freebusy_server() . '/' . $email . '.ifb' . $query; } /**