/** * Perform a complete synchronization. * * @param Horde_Kolab_Storage_Folder_Stamp $stamp The current stamp. * @param array $params Additional parameters. * * @return NULL */ private function _completeSynchronization(Horde_Kolab_Storage_Folder_Stamp $stamp, $params = array()) { $this->_data_cache->reset(); $ids = $stamp->ids(); $params['last_sync'] = false; $params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED] = empty($ids) ? array() : $this->fetch($ids); // logging $uids_to_log = array_keys($params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED]); $this->_logger->debug(sprintf('[KOLAB_STORAGE] Full folder sync details: user: %s, folder: %s, uids: %s', $this->getAuth(), $this->getPath(), implode(', ', $uids_to_log))); $this->_data_cache->store($params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED], $stamp, $this->getVersion()); $params['current_sync'] = $this->_data_cache->getLastSync(); parent::synchronize($params); $this->_data_cache->save(); }
/** * Report the status of this folder. * * @param Horde_Kolab_Storage_Folder_Stamp $previous The previous stamp, * if available. * * @return Horde_Kolab_Storage_Folder_Stamp The stamp that can be used for * detecting folder changes. */ public function getStamp(Horde_Kolab_Storage_Folder_Stamp $previous = null) { if (empty($previous) || $previous->getToken() === false) { $this->_logger->debug('[KOLAB_STORAGE] Fetching stamp without token.'); return $this->_driver->getStamp($this->_folder->getPath()); } try { $this->_logger->debug('[KOLAB_STORAGE] Fetching stamp WITH token.'); return $this->_driver->getStampFromToken($this->_folder->getPath(), $previous->getToken(), $previous->ids()); } catch (Horde_Kolab_Storage_Exception $e) { // Possibly not supported with the current IMAP driver. $this->_logger->debug('[KOLAB_STORAGE] Attempted to fetch stamp with token, but backend did not support.'); return $this->_driver->getStamp($this->_folder->getPath()); } }
/** * What changed between this old stamp and the new provided stamp? * * @param Horde_Kolab_Storage_Folder_Stamp_Uids $stamp The new stamp to * compare against. * * @return array An array of two elements (added IDs, deleted IDs). */ public function getChanges(Horde_Kolab_Storage_Folder_Stamp $stamp) { if (!$stamp instanceof Horde_Kolab_Storage_Folder_Stamp_Uids) { throw new Horde_Kolab_Storage_Exception('This stamp can only be compared against stamps of its own type.'); } return array(self::DELETED => array_values(array_diff($this->ids(), $stamp->ids())), self::ADDED => array_values(array_diff($stamp->ids(), $this->ids()))); }
/** * Perform a complete synchronization. * * @param Horde_Kolab_Storage_Folder_Stamp $stamp The current stamp. * @param array $params Additional parameters. * * @return NULL */ private function _completeSynchronization(Horde_Kolab_Storage_Folder_Stamp $stamp, $params = array()) { $this->_data_cache->reset(); $ids = $stamp->ids(); $params['last_sync'] = false; $params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED] = empty($ids) ? array() : $this->fetch($ids); $this->_data_cache->store($params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED], $stamp, $this->getVersion()); $params['current_sync'] = $this->_data_cache->getLastSync(); parent::synchronize($params); $this->_data_cache->save(); }