Also use DateTime values for recurrence rules; explicitly set last-modified times when savng an object
This commit is contained in:
parent
8f775bc5fc
commit
b23453e3ec
9 changed files with 18 additions and 10 deletions
|
@ -1306,7 +1306,10 @@ class Horde_Date_Recurrence
|
|||
'%04d%02d%02d');
|
||||
$this->setRecurEnd(new Horde_Date(array('year' => $year,
|
||||
'month' => $month,
|
||||
'mday' => $mday)));
|
||||
'mday' => $mday,
|
||||
'hour' => 23,
|
||||
'min' => 59,
|
||||
'sec' => 59)));
|
||||
}
|
||||
if (isset($rdata['COUNT'])) {
|
||||
$this->setRecurCount($rdata['COUNT']);
|
||||
|
|
|
@ -55,7 +55,7 @@ class kolab_date_recurrence
|
|||
$this->engine->fromRRule20($this->to_rrule($object['recurrence'])); // TODO: get that string directly from libkolabxml
|
||||
|
||||
foreach ((array)$object['recurrence']['EXDATE'] as $exdate)
|
||||
$this->engine->addException(date('Y', $exdate), date('n', $exdate), date('j', $exdate));
|
||||
$this->engine->addException($exdate->format('Y'), $exdate->format('n'), $exdate->format('j'));
|
||||
|
||||
$now = new DateTime('now', kolab_format::$timezone);
|
||||
$this->tz_offset = $object['allday'] ? $now->getOffset() - date('Z') : 0;
|
||||
|
@ -124,7 +124,7 @@ class kolab_date_recurrence
|
|||
public function end($limit = 'now +1 year')
|
||||
{
|
||||
if ($this->object['recurrence']['UNTIL'])
|
||||
return $this->object['recurrence']['UNTIL'];
|
||||
return $this->object['recurrence']['UNTIL']->format('U');
|
||||
|
||||
$limit_time = strtotime($limit);
|
||||
while ($next_start = $this->next_start(true)) {
|
||||
|
@ -154,11 +154,11 @@ class kolab_date_recurrence
|
|||
$k = strtoupper($k);
|
||||
switch ($k) {
|
||||
case 'UNTIL':
|
||||
$val = gmdate('Ymd\THis', $val);
|
||||
$val = $val->format('Ymd\THis');
|
||||
break;
|
||||
case 'EXDATE':
|
||||
foreach ((array)$val as $i => $ex)
|
||||
$val[$i] = gmdate('Ymd\THis', $ex);
|
||||
$val[$i] = $ex->format('Ymd\THis');
|
||||
$val = join(',', (array)$val);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ class kolab_format_contact extends kolab_format
|
|||
$this->obj->setUid($object['uid']);
|
||||
|
||||
$object['changed'] = new DateTime('now', self::$timezone);
|
||||
$this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
|
||||
|
||||
// do the hard work of setting object values
|
||||
$nc = new NameComponents;
|
||||
|
|
|
@ -50,6 +50,7 @@ class kolab_format_distributionlist extends kolab_format
|
|||
$this->obj->setUid($object['uid']);
|
||||
|
||||
$object['changed'] = new DateTime('now', self::$timezone);
|
||||
$this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
|
||||
|
||||
$this->obj->setName($object['name']);
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ class kolab_format_event extends kolab_format_xcal
|
|||
if ($recurrence['range-type'] == 'number')
|
||||
$rrule['COUNT'] = intval($recurrence['range']);
|
||||
else if ($recurrence['range-type'] == 'date')
|
||||
$rrule['UNTIL'] = $recurrence['range'];
|
||||
$rrule['UNTIL'] = date_create('@'.$recurrence['range']);
|
||||
|
||||
if ($recurrence['day']) {
|
||||
$byday = array();
|
||||
|
@ -251,7 +251,7 @@ class kolab_format_event extends kolab_format_xcal
|
|||
|
||||
if ($recurrence['exclusion']) {
|
||||
foreach ((array)$recurrence['exclusion'] as $excl)
|
||||
$rrule['EXDATE'][] = strtotime($excl . date(' H:i:s', $rec['start-date'])); // use time of event start
|
||||
$rrule['EXDATE'][] = date_create($excl . date(' H:i:s', $rec['start-date'])); // use time of event start
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class kolab_format_journal extends kolab_format
|
|||
$this->obj->setUid($object['uid']);
|
||||
|
||||
$object['changed'] = new DateTime('now', self::$timezone);
|
||||
$this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
|
||||
|
||||
// TODO: set object propeties
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class kolab_format_note extends kolab_format
|
|||
$this->obj->setUid($object['uid']);
|
||||
|
||||
$object['changed'] = new DateTime('now', self::$timezone);
|
||||
$this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
|
||||
|
||||
// TODO: set object propeties
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
}
|
||||
else if ($until = self::php_datetime($rr->end())) {
|
||||
$until->setTime($object['start']->format('G'), $object['start']->format('i'), 0);
|
||||
$object['recurrence']['UNTIL'] = $until->format('U');
|
||||
$object['recurrence']['UNTIL'] = $until;
|
||||
}
|
||||
|
||||
if (($byday = $rr->byday()) && $byday->size()) {
|
||||
|
@ -169,7 +169,7 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
if ($exceptions = $this->obj->exceptionDates()) {
|
||||
for ($i=0; $i < $exceptions->size(); $i++) {
|
||||
if ($exdate = self::php_datetime($exceptions->get($i)))
|
||||
$object['recurrence']['EXDATE'][] = $exdate->format('U');
|
||||
$object['recurrence']['EXDATE'][] = $exdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,6 +223,7 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
$this->obj->setUid($object['uid']);
|
||||
|
||||
$object['changed'] = new DateTime('now', self::$timezone);
|
||||
$this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
|
||||
|
||||
// increment sequence
|
||||
$this->obj->setSequence($this->obj->sequence()+1);
|
||||
|
|
|
@ -515,7 +515,7 @@ class kolab_storage_cache
|
|||
// extend date range for recurring events
|
||||
if ($object['recurrence']) {
|
||||
$recurrence = new kolab_date_recurrence($object);
|
||||
$sql_data['dtend'] = date('Y-m-d H:i:s', $recurrence->end() ?: strtotime('now +1 year'));
|
||||
$sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +1 year'));
|
||||
}
|
||||
}
|
||||
else if ($objtype == 'task') {
|
||||
|
|
Loading…
Add table
Reference in a new issue