getHistoryPrefixGenerator() public method

Create a prefix factory.
public getHistoryPrefixGenerator ( ) : Horde_Kolab_Storage_HistoryPrefix | Horde_Support_Stub
return Horde_Kolab_Storage_HistoryPrefix | Horde_Support_Stub
Exemplo n.º 1
0
 /**
  * Synchronize any changes with the History driver.
  *
  * @param array $params 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);
     }
 }