ids() 공개 메소드

Return the list of IDs.
public ids ( ) : array
리턴 array ID list.
예제 #1
0
파일: Adapter.php 프로젝트: raz0rsdge/horde
 /**
  * Populates the changes, flags, and categories arrays with data from
  * any messages added/changed on the IMAP server since the last poll.
  *
  * @param array &$changes                             Changes array.
  * @param array &$flags                               Flags array.
  * @param array &$categories                          Categories array.
  * @param Horde_Imap_Client_Fetch_Results $fetch_ret  Fetch results.
  * @param array $options                              Options array.
  * @param integer $modseq                             Current MODSEQ.
  */
 protected function _buildModSeqChanges(&$changes, &$flags, &$categories, $fetch_ret, $options, $modseq)
 {
     // Get custom flags to use as categories.
     $msgFlags = $this->_getMsgFlags();
     // Filter out any changes that we already know about.
     $fetch_keys = $fetch_ret->ids();
     $result_set = array_diff($fetch_keys, $changes);
     foreach ($result_set as $uid) {
         $data = $fetch_ret[$uid];
         // Ensure no changes after the current modseq as reported by the
         // server status have been returned.
         if ($data->getModSeq() <= $modseq) {
             $changes[] = $uid;
             $flags[$uid] = array('read' => array_search(Horde_Imap_Client::FLAG_SEEN, $data->getFlags()) !== false ? 1 : 0);
             if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWOFIVE) {
                 $flags[$uid]['flagged'] = array_search(Horde_Imap_Client::FLAG_FLAGGED, $data->getFlags()) !== false ? 1 : 0;
             }
             if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWELVEONE) {
                 $categories[$uid] = array();
                 foreach ($data->getFlags() as $flag) {
                     if (!empty($msgFlags[Horde_String::lower($flag)])) {
                         $categories[$uid][] = $msgFlags[Horde_String::lower($flag)];
                     }
                 }
             }
         }
     }
 }
예제 #2
0
파일: Base.php 프로젝트: netcon-source/apps
 /**
  * Store FETCH data in cache.
  *
  * @param Horde_Imap_Client_Fetch_Results $data  The fetch results.
  * @param array $options                         Additional options:
  *   - fields: (array) Only update these cache fields.
  *             DEFAULT: Update all cache fields.
  *   - mailbox: (Horde_Imap_Client_Mailbox) The mailbox to update.
  *              DEFAULT: The selected mailbox.
  *   - uidvalid: (integer) The UID validity number.
  *               DEFAULT: UIDVALIDITY discovered via a status() call.
  *
  * @throws Horde_Imap_Client_Exception
  */
 protected function _updateCache(Horde_Imap_Client_Fetch_Results $data, array $options = array())
 {
     $mailbox = empty($options['mailbox']) ? $this->_selected : $options['mailbox'];
     if (!$this->_initCache(empty($options['mailbox']))) {
         return;
     }
     if (in_array(strval($mailbox), $this->_params['cache']['fetch_ignore'])) {
         $this->writeDebug(sprintf("IGNORING cached FETCH data (mailbox: %s)\n", $mailbox), Horde_Imap_Client::DEBUG_INFO);
         return;
     }
     $seq_res = $data->key_type == $data::UID ? null : $this->_getSeqUidLookup($this->getIdsOb($data->ids(), true));
     $tocache = array();
     $status_flags = 0;
     if (isset($this->_init['enabled']['CONDSTORE'])) {
         $status_flags |= Horde_Imap_Client::STATUS_HIGHESTMODSEQ;
     }
     if (empty($options['uidvalid'])) {
         $status_flags |= Horde_Imap_Client::STATUS_UIDVALIDITY;
     }
     $modseq = null;
     $status_res = $this->status($mailbox, $status_flags);
     $uidvalid = isset($status_res['uidvalidity']) ? $status_res['uidvalidity'] : $options['uidvalid'];
     if (count($data)) {
         $cf = empty($options['fields']) ? $this->_params['cache']['fields'] : $this->_cacheFields();
     }
     foreach ($data as $k => $v) {
         $tmp = array();
         foreach ($cf as $key => $val) {
             if ($v->exists($key)) {
                 switch ($key) {
                     case Horde_Imap_Client::FETCH_ENVELOPE:
                         $tmp[$val] = $v->getEnvelope();
                         break;
                     case Horde_Imap_Client::FETCH_FLAGS:
                         /* A FLAGS FETCH can only occur if we are in the
                          * mailbox. So HIGHESTMODSEQ has already been updated.
                          * Ignore flag caching if MODSEQs not available. */
                         if ($modseq = $status_res['highestmodseq']) {
                             $tmp[$val] = $v->getFlags();
                         }
                         break;
                     case Horde_Imap_Client::FETCH_HEADERS:
                         foreach ($this->_temp['headers_caching'] as $label => $hash) {
                             if ($hdr = $v->getHeaders($label)) {
                                 $tmp[$val][$hash] = $hdr;
                             }
                         }
                         break;
                     case Horde_Imap_Client::FETCH_IMAPDATE:
                         $tmp[$val] = $v->getImapDate();
                         break;
                     case Horde_Imap_Client::FETCH_SIZE:
                         $tmp[$val] = $v->getSize();
                         break;
                     case Horde_Imap_Client::FETCH_STRUCTURE:
                         $tmp[$val] = clone $v->getStructure();
                         break;
                 }
             }
         }
         if (!empty($tmp)) {
             $tocache[is_null($seq_res) ? $k : $seq_res['lookup'][$k]] = $tmp;
         }
     }
     $this->_cache->set($mailbox, $tocache, $uidvalid);
     if ($modseq) {
         $metadata = $this->_cache->getMetaData($mailbox, $uidvalid, array(self::CACHE_MODSEQ));
         if (!isset($metadata[self::CACHE_MODSEQ]) || $metadata[self::CACHE_MODSEQ] != $modseq) {
             $this->_updateMetaData($mailbox, array(self::CACHE_MODSEQ => $modseq), $uidvalid);
         }
     }
 }