summaryrefslogtreecommitdiff
path: root/lib/Kolab/CalDAV/Plugin.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-03-20 11:07:17 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-03-20 11:07:17 (GMT)
commit444d8a530861351c4ba1cd8a99b78173affc29d8 (patch)
treee1769313de0f0c3f06704bb45142f80a961590c9 /lib/Kolab/CalDAV/Plugin.php
parente3ec5ce29748b2ad7d1f848faa3dea4512d6de30 (diff)
downloadiRony-444d8a530861351c4ba1cd8a99b78173affc29d8.tar.gz
Pass-through the pre-generatd free/busy data from Kolab's free/busy service
Diffstat (limited to 'lib/Kolab/CalDAV/Plugin.php')
-rw-r--r--lib/Kolab/CalDAV/Plugin.php52
1 files changed, 42 insertions, 10 deletions
diff --git a/lib/Kolab/CalDAV/Plugin.php b/lib/Kolab/CalDAV/Plugin.php
index 70c0f0f..87ccacf 100644
--- a/lib/Kolab/CalDAV/Plugin.php
+++ b/lib/Kolab/CalDAV/Plugin.php
@@ -26,6 +26,7 @@ namespace Kolab\CalDAV;
use Sabre\DAV;
use Sabre\CalDAV;
use Sabre\VObject;
+use Kolab\DAV\Auth\HTTPBasic;
/**
@@ -137,21 +138,52 @@ class Plugin extends CalDAV\Plugin
*/
protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, VObject\Component $request)
{
- return parent::getFreeBusyForEmail($email, $start, $end, $request);
+ $email = preg_replace('/^mailto:/', '', $email);
+
+ // pass-through the pre-generatd free/busy feed from Kolab's free/busy service
+ if ($fburl = \kolab_storage::get_freebusy_url($email)) {
+ // use PEAR::HTTP_Request2 for data fetching
+ // @include_once('HTTP/Request2.php');
+
+ try {
+ $rcube = \rcube::get_instance();
+ $request = new \HTTP_Request2($fburl);
+ $request->setConfig(array(
+ 'store_body' => true,
+ 'follow_redirects' => true,
+ 'ssl_verify_peer' => $rcube->config->get('kolab_ssl_verify_peer', true),
+ ));
+
+ $response = $request->send();
+
+ // authentication required
+ if ($response->getStatus() == 401) {
+ $request->setAuth(HTTPBasic::$current_user, HTTPBasic::$current_pass);
+ $response = $request->send();
+ }
- // TODO: pass-through the pre-generatd free/busy feed from Kolab's free/busy service
+ // success!
+ if ($response->getStatus() == 200) {
+ return array(
+ 'calendar-data' => $response->getBody(),
+ 'request-status' => '2.0;Success',
+ 'href' => 'mailto:' . $email,
+ );
+ }
+ }
+ catch (\Exception $e) {
+ // ignore failures
+ }
+ }
+ else {
+ // generate free/busy data from this user's calendars
+ return parent::getFreeBusyForEmail($email, $start, $end, $request);
+ }
- // not found:
+ // return "not found"
return array(
'request-status' => '3.7;Could not find principal',
'href' => 'mailto:' . $email,
);
-
- // success_
- return array(
- 'calendar-data' => $fbdata,
- 'request-status' => '2.0;Success',
- 'href' => 'mailto:' . $email,
- );
}
} \ No newline at end of file