1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
<?php
require_once 'Horde/iCalendar.php';
require_once 'Horde/Kolab.php';
/**
* Horde Kronolith free/busy driver for the Kolab IMAP Server.
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
*
* $Horde: kronolith/lib/Storage/kolab.php,v 1.4.10.9 2008/01/02 11:32:18 jan Exp $
*
* See the enclosed file COPYING for license information (GPL). If you
* not receive such a file, see also http://www.fsf.org/copyleft/gpl.html.
*
* @author Stuart Binge <omicron@mighty.co.za>
* @package Kronolith
*/
class Kronolith_Storage_kolab extends Kronolith_Storage {
var $_params = array();
function Kronolith_Storage_kolab($user, $params = array())
{
$this->_user = $user;
$this->_params = $params;
}
function search($email, $private_only = false)
{
global $conf;
if (!is_callable('Kolab', 'getServer')) {
$server = $conf['kolab']['imap']['server'];
} else {
$server = Kolab::getServer('imap');
}
$fb_url = sprintf('%s://%s:%d/freebusy/%s.xfb',
$conf['storage']['freebusy']['protocol'],
$server,
$conf['storage']['freebusy']['port'],
$email);
$options['method'] = 'GET';
$options['timeout'] = 5;
$options['allowRedirects'] = true;
if (!empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
$options = array_merge($options, $GLOBALS['conf']['http']['proxy']);
}
require_once 'HTTP/Request.php';
$http = new HTTP_Request($fb_url, $options);
$http->setBasicAuth(Auth::getAuth(), Auth::getCredential('password'));
@$http->sendRequest();
if ($http->getResponseCode() != 200) {
return PEAR::raiseError(sprintf(_("Unable to retrieve free/busy information for %s"),
$email), KRONOLITH_ERROR_FB_NOT_FOUND);
}
$vfb_text = $http->getResponseBody();
$iCal = new Horde_iCalendar;
$iCal->parsevCalendar($vfb_text);
$vfb = &$iCal->findComponent('VFREEBUSY');
if ($vfb === false) {
return PEAR::raiseError(sprintf(_("No free/busy information is available for %s"),
$email), KRONOLITH_ERROR_FB_NOT_FOUND);
}
return $vfb;
}
function store($email, $vfb, $public = false)
{
// We don't care about storing FB info at the moment; we rather let
// Kolab's freebusy.php script auto-generate it for us.
return true;
}
}
|