/**
* Synchronize based on the given folder list.
*
* @param Horde_Kolab_Storage_List_Cache $cache The reference to the cache
* that should reveive the update.
* @param Horde_Kolab_Storage_Folder_Namespace $namespace The namespace handler
* @param array $folder_list The list of folders.
* @param array $annotation The list of folder annotations.
*
* @return NULL
*/
public function _synchronize(Horde_Kolab_Storage_Folder_Namespace $namespace, $folder_list, $annotations)
{
$folders = array();
$owners = array();
$types = array();
$by_type = array();
$mail_type = $this->_folder_types->create('mail');
$this->_defaults->reset();
foreach ($folder_list as $folder) {
$folder = strval($folder);
if (!isset($annotations[$folder])) {
$type = $mail_type;
} else {
$type = $this->_folder_types->create($annotations[$folder]);
}
$folder_type = $type->getType();
$owner = $namespace->getOwner($folder);
$owners[$folder] = $owner;
$types[$folder] = $type->getType();
$data = new Horde_Kolab_Storage_Folder_Data($folder, $type, $namespace);
$dataset = $data->toArray();
$folders[$folder] = $dataset;
$by_type[$folder_type][$folder] = $dataset;
if ($folders[$folder]['default']) {
$this->_defaults->rememberDefault($folder, $folder_type, $owner, $folders[$folder]['namespace'] == Horde_Kolab_Storage_Folder_Namespace::PERSONAL);
}
}
$this->_cache->store($folder_list, $annotations);
if (!$this->_cache->hasNamespace()) {
$this->_cache->setNamespace(serialize($namespace));
}
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::TYPES, $types);
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::FOLDERS, $folders);
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::OWNERS, $owners);
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::BY_TYPE, $by_type);
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::DEFAULTS, $this->_defaults->getDefaults());
$this->_cache->setQuery(Horde_Kolab_Storage_List_Query_List_Cache::PERSONAL_DEFAULTS, $this->_defaults->getPersonalDefaults());
$this->_cache->save();
}