summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-10-04 17:32:21 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-10-04 17:32:21 (GMT)
commitb7d4731d9766a6f13d893b39f80512c266fc513c (patch)
treea7f5becd08401df56f4a3b1e3b1dfb22065eb67d
parent87335f387f9308d24667fd6a62ae6f2dffc2c389 (diff)
downloadroundcubemail-plugins-kolab-b7d4731d9766a6f13d893b39f80512c266fc513c.tar.gz
Let the derrived kolab_storage_cache classes provide the contents of their custom cache record fields
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache.php26
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache_event.php23
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache_file.php18
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache_task.php18
4 files changed, 56 insertions, 29 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 0081d01..eeae046 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -596,32 +596,6 @@ class kolab_storage_cache
protected function _serialize($object)
{
$sql_data = array('changed' => null, 'dtstart' => null, 'dtend' => null, 'xml' => '', 'tags' => '', 'words' => '');
- $objtype = $object['_type'] ? $object['_type'] : $this->folder->type;
-
- // set type specific values
- if ($objtype == 'event') {
- // database runs in server's timezone so using date() is what we want
- $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
- $sql_data['dtend'] = date('Y-m-d H:i:s', is_object($object['end']) ? $object['end']->format('U') : $object['end']);
-
- // extend date range for recurring events
- if ($object['recurrence'] && $object['_formatobj']) {
- $recurrence = new kolab_date_recurrence($object['_formatobj']);
- $sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +1 year'));
- }
- }
- else if ($objtype == 'task') {
- if ($object['start'])
- $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
- if ($object['due'])
- $sql_data['dtend'] = date('Y-m-d H:i:s', is_object($object['due']) ? $object['due']->format('U') : $object['due']);
- }
- else if ($objtype == 'file') {
- if (!empty($object['_attachments'])) {
- reset($object['_attachments']);
- $sql_data['filename'] = $object['_attachments'][key($object['_attachments'])]['name'];
- }
- }
if ($object['changed']) {
$sql_data['changed'] = date('Y-m-d H:i:s', is_object($object['changed']) ? $object['changed']->format('U') : $object['changed']);
diff --git a/plugins/libkolab/lib/kolab_storage_cache_event.php b/plugins/libkolab/lib/kolab_storage_cache_event.php
index a8e7176..69134e7 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_event.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_event.php
@@ -24,5 +24,26 @@
class kolab_storage_cache_event extends kolab_storage_cache
{
protected $extra_cols = array('dtstart','dtend');
-
+
+ /**
+ * Helper method to convert the given Kolab object into a dataset to be written to cache
+ *
+ * @override
+ */
+ protected function _serialize($object)
+ {
+ $sql_data = parent::_serialize($object);
+
+ // database runs in server's timezone so using date() is what we want
+ $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
+ $sql_data['dtend'] = date('Y-m-d H:i:s', is_object($object['end']) ? $object['end']->format('U') : $object['end']);
+
+ // extend date range for recurring events
+ if ($object['recurrence'] && $object['_formatobj']) {
+ $recurrence = new kolab_date_recurrence($object['_formatobj']);
+ $sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +1 year'));
+ }
+
+ return $sql_data;
+ }
} \ No newline at end of file
diff --git a/plugins/libkolab/lib/kolab_storage_cache_file.php b/plugins/libkolab/lib/kolab_storage_cache_file.php
index 3c98f63..ea1823d 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_file.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_file.php
@@ -24,5 +24,21 @@
class kolab_storage_cache_file extends kolab_storage_cache
{
protected $extra_cols = array('filename');
-
+
+ /**
+ * Helper method to convert the given Kolab object into a dataset to be written to cache
+ *
+ * @override
+ */
+ protected function _serialize($object)
+ {
+ $sql_data = parent::_serialize($object);
+
+ if (!empty($object['_attachments'])) {
+ reset($object['_attachments']);
+ $sql_data['filename'] = $object['_attachments'][key($object['_attachments'])]['name'];
+ }
+
+ return $sql_data;
+ }
} \ No newline at end of file
diff --git a/plugins/libkolab/lib/kolab_storage_cache_task.php b/plugins/libkolab/lib/kolab_storage_cache_task.php
index aaf75e6..03facb4 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_task.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_task.php
@@ -24,5 +24,21 @@
class kolab_storage_cache_task extends kolab_storage_cache
{
protected $extra_cols = array('dtstart','dtend');
-
+
+ /**
+ * Helper method to convert the given Kolab object into a dataset to be written to cache
+ *
+ * @override
+ */
+ protected function _serialize($object)
+ {
+ $sql_data = parent::_serialize($object);
+
+ if ($object['start'])
+ $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
+ if ($object['due'])
+ $sql_data['dtend'] = date('Y-m-d H:i:s', is_object($object['due']) ? $object['due']->format('U') : $object['due']);
+
+ return $sql_data;
+ }
} \ No newline at end of file