Horde_Kolab_Storage_Data_Query_History_Base::synchronize PHP Method

synchronize() public method

Synchronize any changes with the History driver.
public synchronize ( array $params = [] )
$params array Additional parameters: - changes: (array) An array of arrays keyed by backend id containing information about each change. If not present, triggers a full history sync. - is_reset: (boolean) If true, indicates that UIDVALIDITY changed.
    public function synchronize($params = array())
    {
        $user = $this->_data->getAuth();
        $folder = $this->_data->getPath();
        // check if IMAP uidvalidity changed
        $is_reset = !empty($params['is_reset']);
        if (isset($params['changes']) && !$is_reset) {
            $added = $params['changes'][Horde_Kolab_Storage_Folder_Stamp::ADDED];
            $deleted = $params['changes'][Horde_Kolab_Storage_Folder_Stamp::DELETED];
            if (!empty($added) || !empty($deleted)) {
                if (!($prefix = $this->_factory->getHistoryPrefixGenerator()->getPrefix($this->_data))) {
                    // Abort history update if we can't determine the prefix.
                    return;
                }
                $this->_logger->debug(sprintf('[KOLAB_STORAGE] Incremental Horde_History update for user: %s, folder: %s, prefix: %s', $user, $folder, $prefix));
            }
            foreach ($added as $bid => $object) {
                $this->_updateLog($prefix . $object['uid'], $bid);
            }
            foreach ($deleted as $bid => $object_uid) {
                // Check if the object is really gone from the folder.
                // Otherwise we just deleted a duplicated object or updated the original one.
                // (An update results in an ADDED + DELETED folder action)
                if ($this->_data->objectIdExists($object_uid) == true) {
                    $this->_logger->debug(sprintf('[KOLAB_STORAGE] Object still existing: object: %s, vanished IMAP uid: %d. Skipping delete from Horde_History.', $object_uid, $bid));
                    continue;
                }
                $this->_logger->debug(sprintf('[KOLAB_STORAGE] Object deleted: uid: %d -> %s, logging in Horde_History.', $bid, $object_uid));
                $this->_history->log($prefix . $object_uid, array('action' => 'delete', 'bid' => $bid), true);
            }
        } else {
            // Full sync. Either our timestamp is too old or the IMAP
            // uidvalidity changed.
            if (!($prefix = $this->_factory->getHistoryPrefixGenerator()->getPrefix($this->_data))) {
                return;
            }
            $this->_logger->debug(sprintf('[KOLAB_STORAGE] Full Horde_History sync for user: %s, folder: %s, is_reset: %d, prefix: %s', $user, $folder, $is_reset, $prefix));
            $this->_completeSynchronization($prefix, $is_reset);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Synchronize the preferences information with the information from the
  * backend.
  *
  * @param array $params Additional parameters.
  *
  * @return NULL
  */
 public function synchronize($params = array())
 {
     if (isset($params['last_sync']) && ($params['last_sync'] === false || $params['last_sync'] !== $this->history->getActionTimestamp(__CLASS__, 'sync'))) {
         /**
          * Ignore current changeset and do a full synchronization as we are
          * out of sync
          */
         unset($params['changes']);
     }
     parent::synchronize($params);
     if (isset($params['current_sync'])) {
         $this->history->log(__CLASS__, array('action' => 'sync', 'ts' => $params['current_sync']));
     }
 }
All Usage Examples Of Horde_Kolab_Storage_Data_Query_History_Base::synchronize