resolveIds() public method

Resolves an IDs object into a list of IDs.
public resolveIds ( Horde_Imap_Client_Mailbox $mailbox, Horde_Imap_Client_Ids $ids, integer $convert ) : Horde_Imap_Client_Ids
$mailbox Horde_Imap_Client_Mailbox The mailbox.
$ids Horde_Imap_Client_Ids The Ids object.
$convert integer Convert to UIDs? - 0: No - 1: Only if $ids is not already a UIDs object - 2: Always
return Horde_Imap_Client_Ids The list of IDs.
コード例 #1
0
ファイル: Sync.php プロジェクト: raz0rsdge/horde
 /**
  * Constructor.
  *
  * @param Horde_Imap_Client_Base $base_ob  Base driver object.
  * @param mixed $mailbox                   Mailbox to sync.
  * @param array $sync                      Token sync data.
  * @param array $curr                      Current sync data.
  * @param integer $criteria                Mask of criteria to return.
  * @param Horde_Imap_Client_Ids $ids       List of known UIDs.
  *
  * @throws Horde_Imap_Client_Exception
  * @throws Horde_Imap_Client_Exception_Sync
  */
 public function __construct(Horde_Imap_Client_Base $base_ob, $mailbox, $sync, $curr, $criteria, $ids)
 {
     foreach (self::$map as $key => $val) {
         if (isset($sync[$key])) {
             $this->{$val} = $sync[$key];
         }
     }
     /* Check uidvalidity. */
     if (!$this->uidvalidity || $curr['V'] != $this->uidvalidity) {
         throw new Horde_Imap_Client_Exception_Sync('UIDs in cached mailbox have changed.', Horde_Imap_Client_Exception_Sync::UIDVALIDITY_CHANGED);
     }
     $this->mailbox = $mailbox;
     /* This was a UIDVALIDITY check only. */
     if (!$criteria) {
         return;
     }
     $sync_all = $criteria & Horde_Imap_Client::SYNC_ALL;
     /* New messages. */
     if ($sync_all || $criteria & Horde_Imap_Client::SYNC_NEWMSGS || $criteria & Horde_Imap_Client::SYNC_NEWMSGSUIDS) {
         $this->newmsgs = empty($this->uidnext) ? !empty($curr['U']) : !empty($curr['U']) && $curr['U'] > $this->uidnext;
         if ($this->newmsgs && ($sync_all || $criteria & Horde_Imap_Client::SYNC_NEWMSGSUIDS)) {
             $new_ids = empty($this->uidnext) ? Horde_Imap_Client_Ids::ALL : $this->uidnext . ':' . $curr['U'];
             $squery = new Horde_Imap_Client_Search_Query();
             $squery->ids(new Horde_Imap_Client_Ids($new_ids));
             $sres = $base_ob->search($mailbox, $squery);
             $this->_newmsgsuids = $sres['match'];
         }
     }
     /* Do single status call to get all necessary data. */
     if ($this->highestmodseq && ($sync_all || $criteria & Horde_Imap_Client::SYNC_FLAGS || $criteria & Horde_Imap_Client::SYNC_FLAGSUIDS || $criteria & Horde_Imap_Client::SYNC_VANISHED || $criteria & Horde_Imap_Client::SYNC_VANISHEDUIDS)) {
         $status_sync = $base_ob->status($mailbox, Horde_Imap_Client::STATUS_SYNCMODSEQ | Horde_Imap_Client::STATUS_SYNCFLAGUIDS | Horde_Imap_Client::STATUS_SYNCVANISHED);
         if (!is_null($ids)) {
             $ids = $base_ob->resolveIds($mailbox, $ids);
         }
     }
     /* Flag changes. */
     if ($sync_all || $criteria & Horde_Imap_Client::SYNC_FLAGS) {
         $this->flags = $this->highestmodseq ? $this->highestmodseq != $curr['H'] : true;
     }
     if ($sync_all || $criteria & Horde_Imap_Client::SYNC_FLAGSUIDS) {
         if ($this->highestmodseq) {
             if ($this->highestmodseq == $status_sync['syncmodseq']) {
                 $this->_flagsuids = is_null($ids) ? $status_sync['syncflaguids'] : $base_ob->getIdsOb(array_intersect($ids->ids, $status_sync['syncflaguids']->ids));
             } else {
                 $squery = new Horde_Imap_Client_Search_Query();
                 $squery->modseq($this->highestmodseq + 1);
                 $sres = $base_ob->search($mailbox, $squery, array('ids' => $ids));
                 $this->_flagsuids = $sres['match'];
             }
         } else {
             /* Without MODSEQ, need to mark all FLAGS as changed. */
             $this->_flagsuids = $base_ob->resolveIds($mailbox, is_null($ids) ? $base_ob->getIdsOb(Horde_Imap_Client_Ids::ALL) : $ids);
         }
     }
     /* Vanished messages. */
     if ($sync_all || $criteria & Horde_Imap_Client::SYNC_VANISHED || $criteria & Horde_Imap_Client::SYNC_VANISHEDUIDS) {
         if ($this->highestmodseq && $this->highestmodseq == $status_sync['syncmodseq']) {
             $vanished = is_null($ids) ? $status_sync['syncvanished'] : $base_ob->getIdsOb(array_intersect($ids->ids, $status_sync['syncvanished']->ids));
         } else {
             $vanished = $base_ob->vanished($mailbox, $this->highestmodseq ? $this->highestmodseq : 1, array('ids' => $ids));
         }
         $this->vanished = (bool) count($vanished);
         $this->_vanisheduids = $vanished;
     }
 }