objectIdExists() public method

Check if the given object ID exists.
public objectIdExists ( string $object_id ) : boolean
$object_id string The object ID.
return boolean True if the ID was found, false otherwise.
Example #1
0
 /**
  * Checks if the event's UID already exists and returns all event
  * ids with that UID.
  *
  * @param string $uid          The event's uid.
  * @param string $calendar_id  Calendar to search in.
  *
  * @return string|boolean  Returns a string with event_id or false if
  *                         not found.
  * @throws Kronolith_Exception
  */
 public function exists($uid, $calendar_id = null)
 {
     // Log error if someone uses this function in an unsupported way
     if ($calendar_id != $this->calendar) {
         throw new BadMethodCallException(sprintf('Kolab::exists called for calendar %s. Currently active is %s.', $calendar_id, $this->calendar));
     }
     $this->synchronize();
     if ($this->_data->objectIdExists($uid)) {
         return $uid;
     }
     return false;
 }
Example #2
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);
     }
 }
Example #3
0
File: Log.php Project: horde/horde
 /**
  * Check if the given object ID exists.
  *
  * @param string $object_id The object ID.
  *
  * @return boolean True if the ID was found, false otherwise.
  */
 public function objectIdExists($object_id)
 {
     return $this->_data->objectIdExists($object_id);
 }