summaryrefslogtreecommitdiff
path: root/plugins/libkolab
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-03-10 13:30:50 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-03-10 13:30:50 (GMT)
commit60205136eeeecc0be3cc62bc5652206d3ab2009e (patch)
tree07c909ebc355d483868a6f6153fdfaa5897b8e54 /plugins/libkolab
parent738cdb70176e67e6d4cc0635e7a9e261e26af1c9 (diff)
downloadroundcubemail-plugins-kolab-60205136eeeecc0be3cc62bc5652206d3ab2009e.tar.gz
Code cleanup: get recurrence instance identifiers from utility functions
Diffstat (limited to 'plugins/libkolab')
-rw-r--r--plugins/libkolab/lib/kolab_date_recurrence.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_event.php6
-rw-r--r--plugins/libkolab/libkolab.php11
3 files changed, 15 insertions, 4 deletions
diff --git a/plugins/libkolab/lib/kolab_date_recurrence.php b/plugins/libkolab/lib/kolab_date_recurrence.php
index b2511f2..f2483c9 100644
--- a/plugins/libkolab/lib/kolab_date_recurrence.php
+++ b/plugins/libkolab/lib/kolab_date_recurrence.php
@@ -90,7 +90,7 @@ class kolab_date_recurrence
$next['start'] = $next_start;
$next['end'] = $next_end;
- $recurrence_id_format = $next['allday'] ? 'Ymd' : 'Ymd\THis';
+ $recurrence_id_format = libkolab::recurrence_id_format($next);
$next['recurrence_date'] = clone $next_start;
$next['_instance'] = $next_start->format($recurrence_id_format);
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index a1ff5b3..e59ddcf 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -102,7 +102,7 @@ class kolab_format_event extends kolab_format_xcal
}
if (is_array($object['exceptions'])) {
- $recurrence_id_format = $object['allday'] ? 'Ymd' : 'Ymd\THis';
+ $recurrence_id_format = libkolab::recurrence_id_format($object);
$vexceptions = new vectorevent;
foreach ($object['exceptions'] as $i => $exception) {
$exevent = new kolab_format_event;
@@ -210,7 +210,7 @@ class kolab_format_event extends kolab_format_xcal
// read exception event objects
if (($exceptions = $this->obj->exceptions()) && is_object($exceptions) && $exceptions->size()) {
$recurrence_exceptions = array();
- $recurrence_id_format = $object['allday'] ? 'Ymd' : 'Ymd\THis';
+ $recurrence_id_format = libkolab::recurrence_id_format($object);
for ($i=0; $i < $exceptions->size(); $i++) {
if (($exobj = $exceptions->get($i))) {
$exception = new kolab_format_event($exobj);
@@ -251,7 +251,7 @@ class kolab_format_event extends kolab_format_xcal
$result = null;
$object = $this->to_array();
- $recurrence_id_format = $object['allday'] ? 'Ymd' : 'Ymd\THis';
+ $recurrence_id_format = libkolab::recurrence_id_format($object);
$instance_id = $recurrence_id instanceof DateTime ? $recurrence_id->format($recurrence_id_format) : strval($recurrence_id);
if ($object['recurrence_date'] instanceof DateTime) {
diff --git a/plugins/libkolab/libkolab.php b/plugins/libkolab/libkolab.php
index 20e7d37..f1c2c87 100644
--- a/plugins/libkolab/libkolab.php
+++ b/plugins/libkolab/libkolab.php
@@ -139,4 +139,15 @@ class libkolab extends rcube_plugin
$diff = new FineDiff($from, $to, FineDiff::$wordGranularity);
return $diff->renderDiffToHTML();
}
+
+ /**
+ * Return a date() format string to render identifiers for recurrence instances
+ *
+ * @param array Hash array with event properties
+ * @return string Format string
+ */
+ public static function recurrence_id_format($event)
+ {
+ return $event['allday'] ? 'Ymd' : 'Ymd\THis';
+ }
}