| | |
| | | */ |
| | | function __construct($db_conn) |
| | | { |
| | | $this->db = $db_conn; |
| | | $this->db = $db_conn; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | // get message count for a specific mailbox; acceptes modes are: ALL, UNSEEN, RECENT |
| | | /** |
| | | * Get message count for a specific mailbox |
| | | * |
| | | * @param string Mailbox/folder name |
| | | * @param string Mode for count [ALL|UNSEEN|RECENT] |
| | | * @param boolean Force reading from server and update cache |
| | | * @return number Number of messages |
| | | * @access public |
| | | */ |
| | | function messagecount($mbox='', $mode='ALL', $force=FALSE) |
| | | { |
| | | $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox; |
| | | return $this->_messagecount($mailbox, $mode, $force); |
| | | } |
| | | |
| | | // private method for getting nr of mesages |
| | | |
| | | /** |
| | | * Private method for getting nr of messages |
| | | * |
| | | * @access private |
| | | * @see rcube_imap::messagecount |
| | | */ |
| | | function _messagecount($mailbox='', $mode='ALL', $force=FALSE) |
| | | { |
| | | $a_mailbox_cache = FALSE; |
| | |
| | | } |
| | | |
| | | |
| | | // public method for listing headers |
| | | // convert mailbox name with root dir first |
| | | /** |
| | | * Public method for listing headers |
| | | * convert mailbox name with root dir first |
| | | * |
| | | * @param string Mailbox/folder name |
| | | * @param number Current page to list |
| | | * @param string Header field to sort by |
| | | * @param string Sort order [ASC|DESC] |
| | | * @return array Indexed array with message header objects |
| | | * @access public |
| | | */ |
| | | function list_headers($mbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL) |
| | | { |
| | | $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox; |
| | |
| | | } |
| | | |
| | | |
| | | // private method for listing message header |
| | | /** |
| | | * Private method for listing message header |
| | | * |
| | | * @access private |
| | | * @see rcube_imap::list_headers |
| | | */ |
| | | function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=FALSE) |
| | | { |
| | | if (!strlen($mailbox)) |
| | |
| | | // cache is OK |
| | | if ($cache_status>0) |
| | | { |
| | | $a_index = $this->get_message_cache_index($cache_key, FALSE, $this->sort_field); |
| | | $a_index = $this->get_message_cache_index($cache_key, TRUE, $this->sort_field, $this->sort_order); |
| | | return array_values($a_index); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | function get_message_cache_index($key, $force=FALSE, $sort_col='idx') |
| | | function get_message_cache_index($key, $force=FALSE, $sort_col='idx', $sort_order='ASC') |
| | | { |
| | | static $sa_message_index = array(); |
| | | |
| | |
| | | FROM ".get_table_name('messages')." |
| | | WHERE user_id=? |
| | | AND cache_key=? |
| | | ORDER BY ".$sort_col." ASC", |
| | | ORDER BY ".$this->db->quote_identifier($sort_col)." ".$sort_order, |
| | | $_SESSION['user_id'], |
| | | $key); |
| | | |
| | |
| | | |
| | | $this->db->query( |
| | | "INSERT INTO ".get_table_name('messages')." |
| | | (user_id, del, cache_key, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers) |
| | | VALUES (?, 0, ?, ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?)", |
| | | (user_id, del, cache_key, created, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers) |
| | | VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?)", |
| | | $_SESSION['user_id'], |
| | | $key, |
| | | $index, |
| | | $headers->uid, |
| | | substr($this->decode_header($headers->subject, TRUE), 0, 128), |
| | | substr($this->decode_header($headers->from, TRUE), 0, 128), |
| | | substr($this->decode_header($headers->to, TRUE), 0, 128), |
| | | substr($this->decode_header($headers->cc, TRUE), 0, 128), |
| | | substr($this->decode_header((string)$headers->subject, TRUE), 0, 128), |
| | | substr($this->decode_header((string)$headers->from, TRUE), 0, 128), |
| | | substr($this->decode_header((string)$headers->to, TRUE), 0, 128), |
| | | substr($this->decode_header((string)$headers->cc, TRUE), 0, 128), |
| | | (int)$headers->size, |
| | | serialize($headers)); |
| | | } |
| | |
| | | $rest = quoted_printable_decode($rest); |
| | | } |
| | | |
| | | return decode_specialchars($rest, $a[0]); |
| | | return rcube_charset_convert($rest, $a[0]); |
| | | } |
| | | else |
| | | return $str; //we dont' know what to do with this |
| | | return $str; // we dont' know what to do with this |
| | | } |
| | | |
| | | |
| | |
| | | function charset_decode($body, $ctype_param) |
| | | { |
| | | if (is_array($ctype_param) && !empty($ctype_param['charset'])) |
| | | return decode_specialchars($body, $ctype_param['charset']); |
| | | return rcube_charset_convert($body, $ctype_param['charset']); |
| | | |
| | | return $body; |
| | | } |