| | |
| | | } |
| | | |
| | | // fetch complete message index |
| | | $msg_count = $this->_messagecount($mailbox); |
| | | if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) |
| | | { |
| | | if ($this->sort_order == 'DESC') |
| | |
| | | } |
| | | else |
| | | { |
| | | $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", $this->sort_field, $this->skip_deleted); |
| | | $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", $this->sort_field, $this->skip_deleted); |
| | | |
| | | if ($this->sort_order=="ASC") |
| | | asort($a_index); |
| | |
| | | // other message at this position |
| | | if (isset($cache_index[$id])) |
| | | { |
| | | $this->remove_message_cache($cache_key, $cache_index[$id]); |
| | | $for_remove[] = $cache_index[$id]; |
| | | unset($cache_index[$id]); |
| | | } |
| | | |
| | | $toupdate[] = $id; |
| | | $for_update[] = $id; |
| | | } |
| | | |
| | | // clear messages at wrong positions and those deleted that are still in cache_index |
| | | if (!empty($for_remove)) |
| | | $cache_index = array_merge($cache_index, $for_remove); |
| | | |
| | | if (!empty($cache_index)) |
| | | $this->remove_message_cache($cache_key, $cache_index); |
| | | |
| | | // fetch complete headers and add to cache |
| | | if (!empty($toupdate)) { |
| | | if ($headers = iil_C_FetchHeader($this->conn, $mailbox, join(',', $toupdate), false, $this->fetch_add_headers)) |
| | | if (!empty($for_update)) { |
| | | if ($headers = iil_C_FetchHeader($this->conn, $mailbox, join(',', $for_update), false, $this->fetch_add_headers)) |
| | | foreach ($headers as $header) |
| | | $this->add_message_cache($cache_key, $header->id, $header); |
| | | } |
| | | |
| | | // those ids that are still in cache_index have been deleted |
| | | if (!empty($cache_index)) |
| | | { |
| | | foreach ($cache_index as $id => $uid) |
| | | $this->remove_message_cache($cache_key, $uid); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // try search with US-ASCII charset (should be supported by server) |
| | | // only if UTF-8 search is not supported |
| | | if (empty($results) && !is_array($results) && !empty($charset) && $charset!='US-ASCII') |
| | | if (empty($results) && !is_array($results) && !empty($charset) && $charset != 'US-ASCII') |
| | | { |
| | | // convert strings to US_ASCII |
| | | if(preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, PREG_OFFSET_CAPTURE)) |
| | |
| | | else // strings for conversion not found |
| | | $res = $str; |
| | | |
| | | $results = $this->search($mbox_name, $res, 'US-ASCII', $sort_field); |
| | | $results = $this->search($mbox_name, $res, NULL, $sort_field); |
| | | } |
| | | |
| | | $this->set_search_set($str, $results, $charset, $sort_field); |
| | |
| | | $cache_key = $mailbox.'.msg'; |
| | | if ($this->caching_enabled) |
| | | { |
| | | foreach ($uids as $uid) |
| | | if ($cached_headers = $this->get_cached_message($cache_key, $uid)) |
| | | $this->remove_message_cache($cache_key, $uid); |
| | | $this->remove_message_cache($cache_key, $uids); |
| | | |
| | | // close and re-open connection |
| | | // this prevents connection problems with Courier |
| | |
| | | } |
| | | |
| | | // clear cache from the lowest index on |
| | | $this->clear_message_cache($cache_key, $start_index); |
| | | if ($start_index < 100000) |
| | | $this->clear_message_cache($cache_key, $start_index); |
| | | } |
| | | |
| | | return $moved; |
| | |
| | | } |
| | | |
| | | // clear cache from the lowest index on |
| | | $this->clear_message_cache($cache_key, $start_index); |
| | | if ($start_index < 100000) |
| | | $this->clear_message_cache($cache_key, $start_index); |
| | | } |
| | | |
| | | return $deleted; |
| | |
| | | /** |
| | | * Remove mailboxes from server |
| | | * |
| | | * @param string Mailbox name |
| | | * @param string Mailbox name(s) string/array |
| | | * @return boolean True on success |
| | | */ |
| | | function delete_mailbox($mbox_name) |
| | |
| | | |
| | | // send delete command to server |
| | | $result = iil_C_DeleteFolder($this->conn, $mailbox); |
| | | if ($result>=0) |
| | | if ($result >= 0) { |
| | | $deleted = TRUE; |
| | | |
| | | $this->clear_message_cache($mailbox.'.msg'); |
| | | } |
| | | |
| | | foreach ($all_mboxes as $c_mbox) |
| | | { |
| | | $regex = preg_quote($mailbox . $this->delimiter, '/'); |
| | |
| | | { |
| | | iil_C_UnSubscribe($this->conn, $c_mbox); |
| | | $result = iil_C_DeleteFolder($this->conn, $c_mbox); |
| | | if ($result>=0) |
| | | if ($result >= 0) { |
| | | $deleted = TRUE; |
| | | } |
| | | $this->clear_message_cache($c_mbox.'.msg'); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // clear mailboxlist cache |
| | | if ($deleted) |
| | | { |
| | | $this->clear_message_cache($mailbox.'.msg'); |
| | | $this->clear_cache('mailboxes'); |
| | | } |
| | | |
| | | return $deleted; |
| | | } |
| | |
| | | $_SESSION['user_id'], |
| | | $key, |
| | | $uid); |
| | | |
| | | if ($sql_arr = $this->db->fetch_assoc($sql_result)) |
| | | { |
| | | $this->cache[$internal_key][$uid] = unserialize($sql_arr['headers']); |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function remove_message_cache($key, $uid) |
| | | function remove_message_cache($key, $uids) |
| | | { |
| | | if (!$this->caching_enabled) |
| | | return; |
| | | |
| | | $this->db->query( |
| | | "DELETE FROM ".get_table_name('messages')." |
| | | WHERE user_id=? |
| | | AND cache_key=? |
| | | AND uid=?", |
| | | WHERE user_id=? |
| | | AND cache_key=? |
| | | AND uid IN (".$this->db->array2list($uids, 'integer').")", |
| | | $_SESSION['user_id'], |
| | | $key, |
| | | $uid); |
| | | $key); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * Convert body charset to UTF-8 according to the ctype_parameters |
| | | * Convert body charset to RCMAIL_CHARSET according to the ctype_parameters |
| | | * |
| | | * @param string Part body to decode |
| | | * @param string Charset to convert from |