5 commits - plugins/libcalendaring plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Jul 24 19:00:08 CEST 2013
plugins/libcalendaring/libcalendaring.php | 2
plugins/libcalendaring/libvcalendar.php | 60 ++++++++++++++------------
plugins/libkolab/lib/kolab_format_event.php | 40 -----------------
plugins/libkolab/lib/kolab_format_xcal.php | 40 +++++++++++++++++
plugins/libkolab/lib/kolab_storage_folder.php | 4 +
5 files changed, 79 insertions(+), 67 deletions(-)
New commits:
commit f15a3feeb4a6f0d38cfecfc5e3f0af2df3c433fa
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jul 24 18:59:57 2013 +0200
Handle attachments and links for all xcal-based objects
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index e050774..f3d0470 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -89,25 +89,6 @@ class kolab_format_event extends kolab_format_xcal
$status = kolabformat::StatusCancelled;
$this->obj->setStatus($status);
- // save attachments
- $vattach = new vectorattachment;
- foreach ((array)$object['_attachments'] as $cid => $attr) {
- if (empty($attr))
- continue;
- $attach = new Attachment;
- $attach->setLabel((string)$attr['name']);
- $attach->setUri('cid:' . $cid, $attr['mimetype']);
- $vattach->push($attach);
- }
-
- foreach ((array)$object['links'] as $link) {
- $attach = new Attachment;
- $attach->setUri($link, null);
- $vattach->push($attach);
- }
-
- $this->obj->setAttachments($vattach);
-
// save recurrence exceptions
if ($object['recurrence']['EXCEPTIONS']) {
$vexceptions = new vectorevent;
@@ -170,27 +151,6 @@ class kolab_format_event extends kolab_format_xcal
else if ($status == kolabformat::StatusCancelled)
$object['cancelled'] = true;
- // handle attachments
- $vattach = $this->obj->attachments();
- for ($i=0; $i < $vattach->size(); $i++) {
- $attach = $vattach->get($i);
-
- // skip cid: attachments which are mime message parts handled by kolab_storage_folder
- if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) {
- $name = $attach->label();
- $content = $attach->data();
- $object['_attachments'][$name] = array(
- 'name' => $name,
- 'mimetype' => $attach->mimetype(),
- 'size' => strlen($content),
- 'content' => $content,
- );
- }
- else if (substr($attach->uri(), 0, 4) == 'http') {
- $object['links'][] = $attach->uri();
- }
- }
-
// read exception event objects
if (($exceptions = $this->obj->exceptions()) && is_object($exceptions) && $exceptions->size()) {
for ($i=0; $i < $exceptions->size(); $i++) {
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index 34f2d81..085e577 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -218,6 +218,27 @@ abstract class kolab_format_xcal extends kolab_format
}
}
+ // handle attachments
+ $vattach = $this->obj->attachments();
+ for ($i=0; $i < $vattach->size(); $i++) {
+ $attach = $vattach->get($i);
+
+ // skip cid: attachments which are mime message parts handled by kolab_storage_folder
+ if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) {
+ $name = $attach->label();
+ $content = $attach->data();
+ $object['_attachments'][$name] = array(
+ 'name' => $name,
+ 'mimetype' => $attach->mimetype(),
+ 'size' => strlen($content),
+ 'content' => $content,
+ );
+ }
+ else if (substr($attach->uri(), 0, 4) == 'http') {
+ $object['links'][] = $attach->uri();
+ }
+ }
+
return $object;
}
@@ -379,6 +400,25 @@ abstract class kolab_format_xcal extends kolab_format
$valarms->push($alarm);
}
$this->obj->setAlarms($valarms);
+
+ // save attachments
+ $vattach = new vectorattachment;
+ foreach ((array)$object['_attachments'] as $cid => $attr) {
+ if (empty($attr))
+ continue;
+ $attach = new Attachment;
+ $attach->setLabel((string)$attr['name']);
+ $attach->setUri('cid:' . $cid, $attr['mimetype']);
+ $vattach->push($attach);
+ }
+
+ foreach ((array)$object['links'] as $link) {
+ $attach = new Attachment;
+ $attach->setUri($link, 'unknown');
+ $vattach->push($attach);
+ }
+
+ $this->obj->setAttachments($vattach);
}
/**
commit 17dbcd9c9f2b0e50fb699abc82c5e58a115387ad
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jul 24 18:59:09 2013 +0200
Validate/fix dates only for event objects; don't export default values
diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php
index 3733101..16a4291 100644
--- a/plugins/libcalendaring/libvcalendar.php
+++ b/plugins/libcalendaring/libvcalendar.php
@@ -191,7 +191,6 @@ class libvcalendar
'changed' => null,
'_type' => $ve->name == 'VTODO' ? 'task' : 'event',
// set defaults
- 'free_busy' => 'busy',
'priority' => 0,
'attendees' => array(),
);
@@ -350,22 +349,25 @@ class libvcalendar
}
}
- // check for all-day dates
- if ($event['start']->_dateonly) {
- $event['allday'] = true;
- }
+ // validate event dates
+ if ($event['_type'] == 'event') {
+ // check for all-day dates
+ if ($event['start']->_dateonly) {
+ $event['allday'] = true;
+ }
- // shift end-date by one day (except Thunderbird)
- if ($event['allday'] && is_object($event['end'])) {
- $event['end']->sub(new \DateInterval('PT23H'));
- }
+ // shift end-date by one day (except Thunderbird)
+ if ($event['allday'] && is_object($event['end'])) {
+ $event['end']->sub(new \DateInterval('PT23H'));
+ }
- // sanity-check and fix end date
- if (empty($event['end'])) {
- $event['end'] = clone $event['start'];
- }
- else if ($event['end'] < $event['start']) {
- $event['end'] = clone $event['start'];
+ // sanity-check and fix end date
+ if (empty($event['end'])) {
+ $event['end'] = clone $event['start'];
+ }
+ else if ($event['end'] < $event['start']) {
+ $event['end'] = clone $event['start'];
+ }
}
// make organizer part of the attendees list for compatibility reasons
@@ -401,7 +403,7 @@ class libvcalendar
if ($trigger)
$event['alarms'] = $trigger . ':' . $action;
}
-
+
// assign current timezone to event start/end
if ($event['start'] instanceof DateTime) {
if ($this->timezone)
@@ -610,7 +612,8 @@ class libvcalendar
$ve->add($cat);
}
- $ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE');
+ if (!empty($event['free_busy']))
+ $ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE');
if ($event['priority'])
$ve->add('PRIORITY', $event['priority']);
@@ -625,7 +628,7 @@ class libvcalendar
if (!empty($event['sensitivity']))
$ve->add('CLASS', strtoupper($event['sensitivity']));
- if (isset($event['complete'])) {
+ if (!empty($event['complete'])) {
$ve->add('PERCENT-COMPLETE', intval($event['complete']));
// Apple iCal required the COMPLETED date to be set in order to consider a task complete
if ($event['complete'] == 100)
commit 2654abfcaf006c4e8920f3f2d1c0281005948b99
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jul 24 18:23:53 2013 +0200
Get around name inconsistencies
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index f046bbf..303ed99 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -650,6 +650,10 @@ class kolab_storage_folder
if (is_array($object['_attachments'])) {
$numatt = count($object['_attachments']);
foreach ($object['_attachments'] as $key => $attachment) {
+ // FIXME: kolab_storage and Roundcube attachment hooks use different fields!
+ if (empty($attachment['content']) && !empty($attachment['data']))
+ $attachment['content'] = $attachment['data'];
+
// make sure size is set, so object saved in cache contains this info
if (!isset($attachment['size'])) {
if (!empty($attachment['content'])) {
commit 7e4559a9b15b8624801ae17a899829d191e3fe78
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jul 24 18:05:40 2013 +0200
Don't set default timezone
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 4beef89..31b731d 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -104,7 +104,7 @@ class libcalendaring extends rcube_plugin
{
$self = self::get_instance();
require_once($self->home . '/libvcalendar.php');
- return new libvcalendar($self->timezone);
+ return new libvcalendar();
}
/**
commit cbc2d067eaed8aceab327d0eeb502940b027afb8
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jul 24 18:05:04 2013 +0200
Don't convert timezone; avoid exporting empty properties
diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php
index e421b60..3733101 100644
--- a/plugins/libcalendaring/libvcalendar.php
+++ b/plugins/libcalendaring/libvcalendar.php
@@ -53,7 +53,7 @@ class libvcalendar
require_once(__DIR__ . '/lib/Sabre/VObject/includes.php');
}
- $this->timezone = $tz ? $tz : new DateTimezone('UTC');
+ $this->timezone = $tz;
$this->prodid = '-//Roundcube//Roundcube libcalendaring ' . RCUBE_VERSION . '//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN';
}
@@ -325,7 +325,7 @@ class libvcalendar
else if (strlen($prop->value) && strtoupper($params['VALUE']) == 'BINARY') {
$attachment = self::map_keys($params, array('FMTTYPE' => 'mimetype', 'X-LABEL' => 'name'));
$attachment['data'] = base64_decode($prop->value);
- $attachment['size'] = strlen($attachment['content']);
+ $attachment['size'] = strlen($attachment['data']);
$event['attachments'][] = $attachment;
}
break;
@@ -404,14 +404,16 @@ class libvcalendar
// assign current timezone to event start/end
if ($event['start'] instanceof DateTime) {
- $event['start']->setTimezone($this->timezone);
+ if ($this->timezone)
+ $event['start']->setTimezone($this->timezone);
}
else {
unset($event['start']);
}
if ($event['end'] instanceof DateTime) {
- $event['end']->setTimezone($this->timezone);
+ if ($this->timezone)
+ $event['end']->setTimezone($this->timezone);
}
else {
unset($event['end']);
@@ -643,10 +645,11 @@ class libvcalendar
if ($attendee['role'] == 'ORGANIZER') {
if (empty($event['organizer']))
$event['organizer'] = $attendee;
- continue;
}
- $attendee['rsvp'] = $attendee['rsvp'] ? 'TRUE' : null;
- $ve->add('ATTENDEE', 'mailto:' . $attendee['email'], self::map_keys($attendee, $this->attendee_keymap));
+ else if (!empty($attendee['email'])) {
+ $attendee['rsvp'] = $attendee['rsvp'] ? 'TRUE' : null;
+ $ve->add('ATTENDEE', 'mailto:' . $attendee['email'], self::map_keys($attendee, $this->attendee_keymap));
+ }
}
if ($event['organizer']) {
@@ -654,7 +657,9 @@ class libvcalendar
}
foreach ((array)$event['url'] as $url) {
- $ve->add('URL', $url);
+ if (!empty($url)) {
+ $ve->add('URL', $url);
+ }
}
if (!empty($event['parent_id'])) {
More information about the commits
mailing list