- implemented regular CalDAV free-busy-query report

- fixed FBTYPE for tentative accepted invitations: BUSY-TENTATIVE
- fixed typo stalling outbox free-busy request
This commit is contained in:
Ralf Becker 2011-09-22 19:49:01 +00:00
parent c631412dfb
commit df1d9e81b2
2 changed files with 43 additions and 4 deletions

View File

@ -123,6 +123,11 @@ class calendar_groupdav extends groupdav_handler
error_log(__METHOD__."($path,".array2string($options).",,$user,$id)");
}
if ($options['root']['name'] == 'free-busy-query')
{
return $this->free_busy_report($path, $options, $user);
}
// ToDo: add parameter to only return id & etag
$filter = array(
'users' => $user,
@ -710,7 +715,7 @@ class calendar_groupdav extends groupdav_handler
$organizer = $component->getAttribute('ORGANIZER');
$attendees = $component->getAttribute('ATTENDEE');
// X-CALENDARSERVER-MASK-UID specifies to exclude given event from busy-time
$mask_uid = $component->getAttribte('X-CALENDARSERVER-MASK-UID');
$mask_uid = $component->getAttribute('X-CALENDARSERVER-MASK-UID');
header('Content-type: text/xml; charset=UTF-8');
@ -751,6 +756,35 @@ class calendar_groupdav extends groupdav_handler
return true;
}
/**
* Handle free-busy-query report
*
* @param string $path
* @param array $options
* @param int $user account_id
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
*/
function free_busy_report($path,$options,$user)
{
if (!$this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user))
{
return '403 Forbidden';
}
foreach($options['other'] as $filter)
{
if ($filter['name'] == 'time-range')
{
$start = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
$end = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
}
}
$handler = $this->_get_handler();
header('Content-Type: text/calendar');
echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok
}
/**
* Return priviledges for current user, default is read and read-current-user-privilege-set
*
@ -982,7 +1016,10 @@ class calendar_groupdav extends groupdav_handler
$props['supported-report-set'] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(
HTTP_WebDAV_Server::mkprop('supported-report',array(
HTTP_WebDAV_Server::mkprop('report',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget','')))))));
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget',''))),
HTTP_WebDAV_Server::mkprop('report',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'free-busy-query',''))),
))));
$props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-data',array(
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));

View File

@ -3088,19 +3088,21 @@ class calendar_ical extends calendar_boupdate
if ($event['non_blocking']) continue;
if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
$fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
if ($utc)
{
$vfreebusy->setAttribute('FREEBUSY',array(array(
'start' => $event['start'],
'end' => $event['end'],
)));
)), array('FBTYPE' => $fbtype));
}
else
{
$vfreebusy->setAttribute('FREEBUSY',array(array(
'start' => date('Ymd\THis',$event['start']),
'end' => date('Ymd\THis',$event['end']),
)));
)), array('FBTYPE' => $fbtype));
}
}
}