Changeset View
Changeset View
Standalone View
Standalone View
lib/kolab_sync_data_tasks.php
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | // $config = $this->getFolderConfig($task['_mailbox']); | ||||
$result['categories'] = $this->getKolabTags($task['uid'], $result['categories']); | $result['categories'] = $this->getKolabTags($task['uid'], $result['categories']); | ||||
// Recurrence | // Recurrence | ||||
$this->recurrence_from_kolab($collection, $task, $result, 'Task'); | $this->recurrence_from_kolab($collection, $task, $result, 'Task'); | ||||
return $as_array ? $result : new Syncroton_Model_Task($result); | return $as_array ? $result : new Syncroton_Model_Task($result); | ||||
} | } | ||||
/** | |||||
* Returns a timezone with an offset matching the difference between $d1 and $d2 | |||||
*/ | |||||
private static function getOffsetTimezone($d1, $d2) | |||||
machniak: Maybe this method should be moved to kolab_sync_timezone_converter. | |||||
{ | |||||
$interval = $d1->diff($d2); | |||||
$tz = new DateTimeZone($interval->format('%R%H%I')); //e.g. +0200 | |||||
$utcOffset = $tz->getOffset(new DateTime('now', $timezone)); | |||||
machniakUnsubmitted Done Inline ActionsUndefined variable $timezone. Also, please see kolab_sync_data::__construct() regarding $this->timezone. This is a user timezone (if set in Roundcube) or server timezone. We should prefer this timezone over any other matching the offset. machniak: Undefined variable $timezone. Also, please see kolab_sync_data::__construct() regarding $this… | |||||
//Look for a timezone with a matching offset. We can't store offsets directly | |||||
foreach (DateTimeZone::listIdentifiers() as $timezoneIdentifier) { | |||||
$timezone = new DateTimeZone($timezoneIdentifier); | |||||
$dt = new DateTime('now', $timezone); | |||||
if ($timezone->getOffset($dt) == $utcOffset) { | |||||
return $timezone; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
/** | /** | ||||
* convert contact from xml to libkolab array | * convert contact from xml to libkolab array | ||||
* | * | ||||
* @param Syncroton_Model_IEntry $data Contact to convert | * @param Syncroton_Model_IEntry $data Contact to convert | ||||
* @param string $folderid Folder identifier | * @param string $folderid Folder identifier | ||||
* @param array $entry Existing entry | * @param array $entry Existing entry | ||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
public function toKolab(Syncroton_Model_IEntry $data, $folderid, $entry = null) | public function toKolab(Syncroton_Model_IEntry $data, $folderid, $entry = null) | ||||
{ | { | ||||
$task = !empty($entry) ? $entry : array(); | $task = !empty($entry) ? $entry : array(); | ||||
$foldername = isset($task['_mailbox']) ? $task['_mailbox'] : $this->getFolderName($folderid); | $foldername = isset($task['_mailbox']) ? $task['_mailbox'] : $this->getFolderName($folderid); | ||||
// $config = $this->getFolderConfig($foldername); | // $config = $this->getFolderConfig($foldername); | ||||
$task['allday'] = 0; | $task['allday'] = 0; | ||||
// Calendar namespace fields | // Calendar namespace fields | ||||
foreach ($this->mapping as $key => $name) { | foreach ($this->mapping as $key => $name) { | ||||
$value = $data->$key; | $value = $data->$key; | ||||
switch ($name) { | switch ($name) { | ||||
case 'due': | |||||
case 'start': | |||||
// We expect to always get regular and utc variants, so we only need to take one into account. | |||||
if ($key == 'utcStartDate' || $key == 'utcDueDate') { | |||||
continue 2; | |||||
} | |||||
if ($value) { | |||||
if ($name =='due' && $data->utcDueDate) { | |||||
$tz = static::getOffsetTimezone($data->utcDueDate, $value); | |||||
if ($tz) { | |||||
//Setting the timezone will change the time, so we set it on the utc variant instead to end up with what we want. | |||||
$value = $data->utcDueDate; | |||||
$value->setTimezone($tz); | |||||
} | |||||
} | |||||
} | |||||
break; | |||||
case 'sensitivity': | case 'sensitivity': | ||||
$map = array_flip($this->sensitivityMap); | $map = array_flip($this->sensitivityMap); | ||||
$value = $map[$value]; | $value = $map[$value]; | ||||
break; | break; | ||||
case 'description': | case 'description': | ||||
$value = $this->getBody($value, Syncroton_Model_EmailBody::TYPE_PLAINTEXT); | $value = $this->getBody($value, Syncroton_Model_EmailBody::TYPE_PLAINTEXT); | ||||
// If description isn't specified keep old description | // If description isn't specified keep old description | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |
Maybe this method should be moved to kolab_sync_timezone_converter.