summaryrefslogtreecommitdiff
path: root/lib/Kolab/CalDAV/CalendarBackend.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-03-14 16:48:10 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-03-14 16:48:10 (GMT)
commit5515a4b398f4ccc2b6f32d810d4fb7eed47c3efa (patch)
tree48700a1f304ebe736d70d5a8889d619f4204579a /lib/Kolab/CalDAV/CalendarBackend.php
parent5ec426a349db1bf8720228b4df4d08388a59b8ab (diff)
downloadiRony-5515a4b398f4ccc2b6f32d810d4fb7eed47c3efa.tar.gz
- Use UIDs from IMAP annoations for collection IDs
- Implement CardDAV/AddressBook classes for proper ACL/sharing support - Enable Free-Busy queries to CalDAV
Diffstat (limited to 'lib/Kolab/CalDAV/CalendarBackend.php')
-rw-r--r--lib/Kolab/CalDAV/CalendarBackend.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/Kolab/CalDAV/CalendarBackend.php b/lib/Kolab/CalDAV/CalendarBackend.php
index 7b0dee8..fe642bc 100644
--- a/lib/Kolab/CalDAV/CalendarBackend.php
+++ b/lib/Kolab/CalDAV/CalendarBackend.php
@@ -28,6 +28,7 @@ use \rcube;
use \rcube_charset;
use \kolab_storage;
use \libcalendaring;
+use Kolab\Utils\DAVBackend;
use Kolab\Utils\VObjectUtils;
use Sabre\CalDAV;
use Sabre\VObject;
@@ -67,7 +68,7 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
asort($names, SORT_LOCALE_STRING);
foreach ($names as $utf7name => $name) {
- $id = urlencode($utf7name);
+ $id = DAVBackend::get_uid($folders[$utf7name]);
$folder = $this->folders[$id] = $folders[$utf7name];
$fdata = $folder->get_imap_data(); // fetch IMAP folder data for CTag generation
$this->calendars[$id] = array(
@@ -104,8 +105,7 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
return $this->folders[$id];
}
else {
- $storage = kolab_storage::get_folder(urldecode($id));
- return !PEAR::isError($this->storage) ? $storage : null;
+ return DAVBackend::get_storage_folder($id, 'event');
}
}
@@ -169,7 +169,7 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
console(__METHOD__, $calendarUri, $properties);
$props = array(
- 'name' => $calendarUri,
+ 'name' => 'Untitled',
'type' => 'event',
'subscribed' => true
);
@@ -177,7 +177,9 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
foreach ($properties as $prop => $val) {
switch ($prop) {
case '{DAV:}displayname':
- // ignore for creating, URI is used
+ $parts = explode('/', $val);
+ $props['name'] = array_pop($parts);
+ $props['parent'] = join('/', $parts);
break;
case '{http://apple.com/ns/ical/}calendar-color':
@@ -189,7 +191,7 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
}
}
- if (!empty($props['name']) && !kolab_storage::folder_update($props)) {
+ if (!empty($props['name']) && ($fname = kolab_storage::folder_update($props))) {
rcube::raise_error(array(
'code' => 600, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
@@ -197,6 +199,11 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
true, false);
return false;
}
+
+ // save UID in folder annotations
+ if ($folder = kolab_storage::get_folder($fname)) {
+ DAVBackend::set_uid($folder, $calendarUri);
+ }
}
/**
@@ -554,10 +561,18 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
*/
public function calendarQuery($calendarId, array $filters)
{
- console(__METHOD__, $calendarId);
+ console(__METHOD__, $calendarId, $filters);
- // TODO: build kolab storage query from $filters
+ // build kolab storage query from $filters
$query = array();
+ foreach ((array)$filters['comp-filters'] as $filter) {
+ if ($filter['name'] != 'VEVENT')
+ continue;
+ if (is_array($filter['time-range'])) {
+ $query[] = array('dtstart', '<=', $filter['time-range']['end']);
+ $query[] = array('dtend', '>=', $filter['time-range']['start']);
+ }
+ }
$results = array();
if ($storage = $this->get_storage_folder($calendarId)) {
@@ -846,7 +861,7 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
if ($event['location'])
$ve->add('LOCATION', $event['location']);
if ($event['description'])
- $ve->add('DESCRIPTION', $event['description']);
+ $ve->add('DESCRIPTION', strtr($event['description'], array("\r\n" => "\n", "\r" => "\n")));
if ($event['sequence'])
$ve->add('SEQUENCE', $event['sequence']);