/**
* Synchronize the query data with the information from the backend.
*
* @param array $params Additional parameters.
*
* @return NULL
*/
public function synchronize($params = array())
{
$current = $this->getStamp();
if (!$this->_data_cache->isInitialized()) {
$this->_completeSynchronization($current);
return;
}
$previous = unserialize($this->_data_cache->getStamp());
if ($previous === false || $previous->isReset($current)) {
$this->_completeSynchronization($current);
return;
}
if (!isset($params['changes'])) {
$changes = $previous->getChanges($current);
$params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED] = $this->fetch($changes[Horde_Kolab_Storage_Folder_Stamp::ADDED]);
$params['changes'][Horde_Kolab_Storage_Folder_Stamp::DELETED] = $this->_data_cache->backendMap($changes[Horde_Kolab_Storage_Folder_Stamp::DELETED]);
}
if ($params['changes'] !== false) {
$params['last_sync'] = $this->_data_cache->getLastSync();
$this->_data_cache->store($params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED], $current, $this->getVersion(), $params['changes'][Horde_Kolab_Storage_Folder_Stamp::DELETED]);
$params['current_sync'] = $this->_data_cache->getLastSync();
parent::synchronize($params);
$this->_data_cache->save();
}
$this->_init = true;
}