Let the derrived kolab_storage_cache classes provide the contents of their custom cache record fields
This commit is contained in:
parent
87335f387f
commit
b7d4731d97
4 changed files with 56 additions and 29 deletions
|
@ -596,32 +596,6 @@ class kolab_storage_cache
|
||||||
protected function _serialize($object)
|
protected function _serialize($object)
|
||||||
{
|
{
|
||||||
$sql_data = array('changed' => null, 'dtstart' => null, 'dtend' => null, 'xml' => '', 'tags' => '', 'words' => '');
|
$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']) {
|
if ($object['changed']) {
|
||||||
$sql_data['changed'] = date('Y-m-d H:i:s', is_object($object['changed']) ? $object['changed']->format('U') : $object['changed']);
|
$sql_data['changed'] = date('Y-m-d H:i:s', is_object($object['changed']) ? $object['changed']->format('U') : $object['changed']);
|
||||||
|
|
|
@ -25,4 +25,25 @@ class kolab_storage_cache_event extends kolab_storage_cache
|
||||||
{
|
{
|
||||||
protected $extra_cols = array('dtstart','dtend');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,4 +25,20 @@ class kolab_storage_cache_file extends kolab_storage_cache
|
||||||
{
|
{
|
||||||
protected $extra_cols = array('filename');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,4 +25,20 @@ class kolab_storage_cache_task extends kolab_storage_cache
|
||||||
{
|
{
|
||||||
protected $extra_cols = array('dtstart','dtend');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue