Get metadata information for a mailbox.
public getMetaData ( string $mailbox, integer $uidvalid = null, array $entries = [] ) : array | ||
$mailbox | string | An IMAP mailbox string. |
$uidvalid | integer | The IMAP uidvalidity value of the mailbox. |
$entries | array | An array of entries to return. If empty, returns all metadata. |
Результат | array | The requested metadata. Requested entries that do not exist will be undefined. The following entries are defaults and always present: - uidvalid: (integer) The UIDVALIDITY of the mailbox. |
/** * Updates the cached MODSEQ value. * * @param integer $modseq MODSEQ value to store. * * @return mixed The MODSEQ of the old value if it was replaced (or false * if it didn't exist or is the same). */ protected function _updateModSeq($modseq) { if (!$this->_initCache(true)) { return false; } $mbox_ob = $this->_mailboxOb(); $uidvalid = $mbox_ob->getStatus(Horde_Imap_Client::STATUS_UIDVALIDITY); $md = $this->_cache->getMetaData($this->_selected, $uidvalid, array(self::CACHE_MODSEQ)); if (isset($md[self::CACHE_MODSEQ])) { if ($md[self::CACHE_MODSEQ] < $modseq) { $set = true; $sync = $md[self::CACHE_MODSEQ]; } else { $set = false; $sync = 0; } $mbox_ob->setStatus(Horde_Imap_Client::STATUS_SYNCMODSEQ, $md[self::CACHE_MODSEQ]); } else { $set = true; $sync = 0; } /* $modseq can be 0 - NOMODSEQ - so don't store in that case. */ if ($set && $modseq) { $this->_cache->setMetaData($this->_selected, $uidvalid, array(self::CACHE_MODSEQ => $modseq)); } return $sync; }
/** * Synchronizes the current mailbox cache with the server. */ protected function _syncMailbox() { $status = $this->status($this->_selected, Horde_Imap_Client::STATUS_UIDVALIDITY | Horde_Imap_Client::STATUS_HIGHESTMODSEQ); /* Check that modseqs are available in mailbox. */ if (empty($status['highestmodseq'])) { return; } /* Grab all flags updated since the cached modseq. */ $md = $this->_cache->getMetaData($this->_selected, $status['uidvalidity'], array(self::CACHE_MODSEQ)); if (!isset($md[self::CACHE_MODSEQ]) || $md[self::CACHE_MODSEQ] == $status['highestmodseq']) { return; } $uids = $this->_cache->get($this->_selected, array(), array(), $status['uidvalidity']); if (!empty($uids)) { $uids_ob = $this->getIdsOb($uids); /* Are we caching flags? */ if (array_key_exists(Horde_Imap_Client::FETCH_FLAGS, $this->_cacheFields())) { $fquery = new Horde_Imap_Client_Fetch_Query(); $fquery->flags(); /* Update flags in cache. Cache will be updated in _fetch(). */ $this->_fetch(new Horde_Imap_Client_Fetch_Results(), $fquery, array('changedsince' => $md[self::CACHE_MODSEQ], 'ids' => $uids_ob)); } /* Search for deleted messages, and remove from cache. */ $squery = new Horde_Imap_Client_Search_Query(); $squery->ids($this->getIdsOb($uids_ob->range_string)); $search = $this->search($this->_selected, $squery, array('nocache' => true)); $deleted = array_diff($uids_ob->ids, $search['match']->ids); if (!empty($deleted)) { $this->_deleteMsgs($this->_selected, $deleted); } } $this->_updateMetaData($this->_selected, array(self::CACHE_MODSEQ => $status['highestmodseq']), $status['uidvalidity']); }