/** * 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(); }
public function testID() { $cache = $this->getMockCache(); $list_cache = new Horde_Kolab_Storage_List_Cache($cache, array('host' => 'test', 'port' => '0', 'user' => 'test')); //$list_cache->setListId('test'); $list_cache->store(array(), array()); $list_cache->save(); $data = unserialize($cache->loadList($list_cache->getListId())); $this->assertEquals('a:3:{s:4:"host";s:4:"test";s:4:"port";s:1:"0";s:4:"user";s:4:"test";}', $data['I']); }