summaryrefslogtreecommitdiff
path: root/plugins/libcalendaring/libcalendaring.php
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/libcalendaring/libcalendaring.php
parent738cdb70176e67e6d4cc0635e7a9e261e26af1c9 (diff)
downloadroundcubemail-plugins-kolab-60205136eeeecc0be3cc62bc5652206d3ab2009e.tar.gz
Code cleanup: get recurrence instance identifiers from utility functions
Diffstat (limited to 'plugins/libcalendaring/libcalendaring.php')
-rw-r--r--plugins/libcalendaring/libcalendaring.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 4f277cf..f25818f 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -1427,8 +1427,7 @@ class libcalendaring extends rcube_plugin
}
// set instance and 'savemode' according to recurrence-id
else if (!empty($object['recurrence_date']) && is_a($object['recurrence_date'], 'DateTime')) {
- $recurrence_id_format = $object['allday'] ? 'Ymd' : 'Ymd\THis';
- $object['_instance'] = $object['recurrence_date']->format($recurrence_id_format);
+ $object['_instance'] = self::recurrence_instance_identifier($object);
$object['_savemode'] = $object['thisandfuture'] ? 'future' : 'current';
}
else if (!empty($object['recurrence_id']) && !empty($object['_instance'])) {
@@ -1441,6 +1440,36 @@ class libcalendaring extends rcube_plugin
}
}
+ /**
+ * 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';
+ }
+
+ /**
+ * Return the identifer for the given instance of a recurring event
+ *
+ * @param array Hash array with event properties
+ * @return mixed Format string or null if identifier cannot be generated
+ */
+ public static function recurrence_instance_identifier($event)
+ {
+ $instance_date = $event['recurrence_date'] ?: $event['start'];
+
+ if ($instance_date && is_a($instance_date, 'DateTime')) {
+ $recurrence_id_format = $event['allday'] ? 'Ymd' : 'Ymd\THis';
+ return $instance_date->format($recurrence_id_format);
+ }
+
+ return null;
+ }
+
+
/********* Attendee handling functions *********/
/**