getIdsOb() 공개 메소드

Returns the correct IDs object for use with this driver.
public getIdsOb ( mixed $ids = null, boolean $sequence = false ) : Horde_Imap_Client_Ids
$ids mixed See add().
$sequence boolean Are $ids message sequence numbers?
리턴 Horde_Imap_Client_Ids The IDs object.
예제 #1
0
 /**
  * Query the validity of a charset.
  *
  * @param string $charset  The charset to query.
  * @param boolean $cached  If true, only query cached values.
  *
  * @return boolean  True if the charset is valid for searching.
  */
 public function query($charset, $cached = false)
 {
     $charset = Horde_String::upper($charset);
     if (isset($this->_charsets[$charset])) {
         return $this->_charsets[$charset];
     } elseif ($cached) {
         return null;
     }
     if (!$this->_baseob) {
         throw new RuntimeException('Base object needs to be defined to query for charset.');
     }
     /* Use a dummy search query and search for BADCHARSET response. */
     $query = new Horde_Imap_Client_Search_Query();
     $query->charset($charset, false);
     $query->ids($this->_baseob->getIdsOb(1, true));
     $query->text('a');
     try {
         $this->_baseob->search('INBOX', $query, array('nocache' => true, 'sequence' => true));
         $this->_charsets[$charset] = true;
     } catch (Horde_Imap_Client_Exception $e) {
         $this->_charsets[$charset] = $e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET;
     }
     $this->notify();
     return $this->_charsets[$charset];
 }
예제 #2
0
 /**
  * Delete messages in the cache.
  *
  * @param string $mailbox  An IMAP mailbox string.
  * @param array $uids      The list of message UIDs to delete.
  */
 public function deleteMsgs($mailbox, $uids)
 {
     if (empty($uids)) {
         return;
     }
     $mailbox = strval($mailbox);
     $this->_loadSliceMap($mailbox);
     $slicemap =& $this->_slicemap[$mailbox];
     $update = array_intersect_key($slicemap['s'], array_flip(is_array($uids) ? $uids : iterator_to_array($uids)));
     if (!empty($update)) {
         $this->_loadUids($mailbox, array_keys($update));
         $d =& $this->_data[$mailbox];
         foreach (array_keys($update) as $id) {
             unset($d[$id], $slicemap['s'][$id]);
         }
         foreach (array_unique($update) as $slice) {
             /* Get rid of slice if less than 10% of capacity. */
             if ($slice != $slicemap['i'] && ($slice_uids = array_keys($slicemap['s'], $slice)) && $this->_params['slicesize'] * 0.1 > count($slice_uids)) {
                 $this->_toUpdate($mailbox, 'add', $slice_uids);
                 $this->_cache->expire($this->_getCid($mailbox, $slice));
                 foreach ($slice_uids as $val) {
                     unset($slicemap['s'][$val]);
                 }
             } else {
                 $this->_toUpdate($mailbox, 'slice', array($slice));
             }
         }
         if ($this->_params['debug']) {
             $this->_base->writeDebug('CACHE: Deleted messages (mailbox: ' . $mailbox . '; UIDs: ' . $this->_base->getIdsOb(array_keys($update))->tostring_sort . ")\n", Horde_Imap_Client::DEBUG_INFO);
         }
     }
 }
예제 #3
0
파일: Cache.php 프로젝트: evltuma/moodle
 /**
  * Delete messages in the cache.
  *
  * @param string $mailbox  An IMAP mailbox string.
  * @param array $uids      The list of message UIDs to delete.
  */
 public function deleteMsgs($mailbox, $uids)
 {
     if (empty($uids)) {
         return;
     }
     $mailbox = strval($mailbox);
     $this->_backend->deleteMsgs($mailbox, $uids);
     if ($this->_debug) {
         $this->_debug->info(sprintf('CACHE: Deleted messages [%s; %s]', $mailbox, $this->_baseob->getIdsOb($uids)->tostring_sort));
     }
 }
예제 #4
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;
     }
 }