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); | ||||
} | } | ||||
/** | |||||
* Apply a timezone matching the utc offset. | |||||
*/ | |||||
private static function applyTimezone($value, $utcValue) | |||||
machniak: Maybe this method should be moved to kolab_sync_timezone_converter. | |||||
{ | |||||
$tzc = kolab_sync_timezone_converter::getInstance(); | |||||
$tz = $tzc->getOffsetTimezone($value, $utcValue); | |||||
if ($tz) { | |||||
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… | |||||
//Setting the timezone will change the time, so we set it on the utc variant instead to end up with the same time in the new timezone. | |||||
$value = $utcValue; | |||||
$value->setTimezone($tz); | |||||
} | |||||
return $value; | |||||
} | |||||
/** | /** | ||||
* 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) { | |||||
$value = static::applyTimezone($value, $data->utcDueDate); | |||||
} | |||||
if ($name =='start' && $data->utcStartDate) { | |||||
$value = static::applyTimezone($value, $data->utcStartDate); | |||||
} | |||||
} | |||||
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.