Exemplo n.º 1
0
 /**
  * Fetches message headers
  * Used for loop
  *
  * @param  string  Mailbox name
  * @param  string  Message index to fetch
  * @param  array   Reference to message headers array
  * @param  array   Array with cache index
  * @return int     Messages count
  * @access private
  */
 private function _fetch_headers($mailbox, $msgs, &$a_msg_headers, $cache_key)
 {
     // fetch reqested headers from server
     $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs, false, false, $this->fetch_add_headers);
     if (!empty($a_header_index)) {
         // cache is incomplete
         $cache_index = $this->get_message_cache_index($cache_key);
         foreach ($a_header_index as $i => $headers) {
             if ($this->caching_enabled && $cache_index[$headers->id] != $headers->uid) {
                 // prevent index duplicates
                 if ($cache_index[$headers->id]) {
                     $this->remove_message_cache($cache_key, $headers->id, true);
                     unset($cache_index[$headers->id]);
                 }
                 // add message to cache
                 $this->add_message_cache($cache_key, $headers->id, $headers, NULL, !in_array($headers->uid, $cache_index));
             }
             $a_msg_headers[$headers->uid] = $headers;
         }
     }
     return count($a_msg_headers);
 }
Exemplo n.º 2
0
 /**
  * Fetches message headers
  * Used for loop
  *
  * @param  string  Mailbox name
  * @param  string  Message index to fetch
  * @param  array   Reference to message headers array
  * @param  array   Array with cache index
  * @return int     Number of deleted messages
  * @access private
  */
 function _fetch_headers($mailbox, $msgs, &$a_msg_headers, $cache_key)
 {
     // cache is incomplete
     $cache_index = $this->get_message_cache_index($cache_key);
     // fetch reuested headers from server
     $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs);
     $deleted_count = 0;
     if (!empty($a_header_index)) {
         foreach ($a_header_index as $i => $headers) {
             if ($headers->deleted && $this->skip_deleted) {
                 // delete from cache
                 if ($cache_index[$headers->id] && $cache_index[$headers->id] == $headers->uid) {
                     $this->remove_message_cache($cache_key, $headers->id);
                 }
                 $deleted_count++;
                 continue;
             }
             // add message to cache
             if ($this->caching_enabled && $cache_index[$headers->id] != $headers->uid) {
                 $this->add_message_cache($cache_key, $headers->id, $headers);
             }
             $a_msg_headers[$headers->uid] = $headers;
         }
     }
     return $deleted_count;
 }