From 78c7947bf8820aba5d45787883a4e7780854f628 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Sun, 02 Aug 2009 03:54:10 -0400 Subject: [PATCH] - Add rcube_imap::unset_flag (#1486017) --- program/include/rcube_imap.php | 49 ++++++++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 21 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 394b0d7..aaa7784 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -1035,14 +1035,6 @@ } else $a_messages = iil_C_Search($this->conn, $mailbox, ($charset ? "CHARSET $charset " : '') . $criteria); - - // clean message list (there might be some empty entries) - if (is_array($a_messages)) - { - foreach ($a_messages as $i => $val) - if (empty($val)) - unset($a_messages[$i]); - } // update messagecount cache ? // $a_mailbox_cache = get_cache('messagecount'); @@ -1162,7 +1154,7 @@ // write structure to cache if ($this->caching_enabled) - $this->add_message_cache($cache_key, $msg_id, $headers, $struct); + $this->add_message_cache($cache_key, $this->_msg_id, $headers, $struct); } return $struct; @@ -1442,6 +1434,10 @@ { $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $uid, true); $structure = iml_GetRawStructureArray($structure_str); + // error or message not found + if (empty($structure)) + return false; + $part_type = iml_GetPartTypeCode($structure, $part); $o_part = new rcube_message_part; $o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other'); @@ -1455,7 +1451,7 @@ $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $uid, true, $part, $o_part->encoding, $print, $fp); - + if ($fp || $print) return true; @@ -1538,12 +1534,8 @@ if (!is_array($uids)) $uids = explode(',',$uids); - if ($flag=='UNDELETED') - $result = iil_C_Undelete($this->conn, $mailbox, join(',', $uids)); - else if ($flag=='UNSEEN') - $result = iil_C_Unseen($this->conn, $mailbox, join(',', $uids)); - else if ($flag=='UNFLAGGED') - $result = iil_C_UnFlag($this->conn, $mailbox, join(',', $uids), 'FLAGGED'); + if (strpos($flag, 'UN') === 0) + $result = iil_C_UnFlag($this->conn, $mailbox, join(',', $uids), substr($flag, 2)); else $result = iil_C_Flag($this->conn, $mailbox, join(',', $uids), $flag); @@ -1570,6 +1562,21 @@ $this->_set_messagecount($mailbox, 'ALL', $count*(-1)); return $result; + } + + + /** + * Remove message flag for one or several messages + * + * @param mixed Message UIDs as array or as comma-separated string + * @param string Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT + * @param string Folder name + * @return boolean True on success, False on failure + * @see set_flag + */ + function unset_flag($uids, $flag, $mbox_name=NULL) + { + return $this->set_flag($uids, 'UN'.$flag, $mbox_name); } @@ -2401,10 +2408,10 @@ $key, $index, $headers->uid, - (string)rc_substr($this->db->encode($this->decode_header($headers->subject, TRUE)), 0, 128), - (string)rc_substr($this->db->encode($this->decode_header($headers->from, TRUE)), 0, 128), - (string)rc_substr($this->db->encode($this->decode_header($headers->to, TRUE)), 0, 128), - (string)rc_substr($this->db->encode($this->decode_header($headers->cc, TRUE)), 0, 128), + (string)mb_substr($this->db->encode($this->decode_header($headers->subject, TRUE)), 0, 128), + (string)mb_substr($this->db->encode($this->decode_header($headers->from, TRUE)), 0, 128), + (string)mb_substr($this->db->encode($this->decode_header($headers->to, TRUE)), 0, 128), + (string)mb_substr($this->db->encode($this->decode_header($headers->cc, TRUE)), 0, 128), (int)$headers->size, serialize($this->db->encode(clone $headers)), is_object($struct) ? serialize($this->db->encode(clone $struct)) : NULL @@ -2792,7 +2799,7 @@ if (($p = array_search(strtolower($folder), $this->default_folders_lc)) !== false && !$a_defaults[$p]) $a_defaults[$p] = $folder; else - $folders[$folder] = rc_strtolower(rcube_charset_convert($folder, 'UTF7-IMAP')); + $folders[$folder] = mb_strtolower(rcube_charset_convert($folder, 'UTF7-IMAP')); } // sort folders and place defaults on the top -- Gitblit v1.9.1