diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_imap.php | 11 | ||||
-rw-r--r-- | program/include/rcube_imap_generic.php | 73 |
2 files changed, 50 insertions, 34 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index d08554206..028d998c3 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2474,8 +2474,7 @@ class rcube_imap } // move messages - $move = $this->conn->move($uids, $from_mbox, $to_mbox); - $moved = !($move === false || $move < 0); + $moved = $this->conn->move($uids, $from_mbox, $to_mbox); // send expunge command in order to have the moved message // really deleted from the source mailbox @@ -2536,8 +2535,9 @@ class rcube_imap list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox); // exit if no message uids are specified - if (empty($uids)) + if (empty($uids)) { return false; + } // make sure mailbox exists if ($to_mbox != 'INBOX' && !$this->mailbox_exists($tbox, true)) { @@ -2548,8 +2548,7 @@ class rcube_imap } // copy messages - $copy = $this->conn->copy($uids, $from_mbox, $to_mbox); - $copied = !($copy === false || $copy < 0); + $copied = $this->conn->copy($uids, $from_mbox, $to_mbox); if ($copied) { $this->_clear_messagecount($to_mbox); @@ -3650,7 +3649,7 @@ class rcube_imap if (!$msg_count) return $cache_count ? -2 : 1; - if ($cache_count==$msg_count) { + if ($cache_count == $msg_count) { if ($this->skip_deleted) { $h_index = $this->conn->fetchHeaderIndex($mailbox, "1:*", 'UID', $this->skip_deleted); diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index e9a5a2d44..5d16dc0c1 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -1199,35 +1199,52 @@ class rcube_imap_generic return implode(',', $result); } - function UID2ID($folder, $uid) + /** + * Returns message sequence identifier + * + * @param string $mailbox Mailbox name + * @param int $uid Message unique identifier (UID) + * + * @return int Message sequence identifier + * @access public + */ + function UID2ID($mailbox, $uid) { if ($uid > 0) { - $id_a = $this->search($folder, "UID $uid"); + $id_a = $this->search($mailbox, "UID $uid"); if (is_array($id_a) && count($id_a) == 1) { - return $id_a[0]; + return (int) $id_a[0]; } } - return false; + return null; } - function ID2UID($folder, $id) + /** + * Returns message unique identifier (UID) + * + * @param string $mailbox Mailbox name + * @param int $uid Message sequence identifier + * + * @return int Message unique identifier + * @access public + */ + function ID2UID($mailbox, $id) { - if (empty($id)) { - return -1; + if (empty($id) || $id < 0) { + return null; } if (!$this->select($folder)) { - return -1; + return null; } - $result = -1; list($code, $response) = $this->execute('FETCH', array($id, '(UID)')); if ($code == self::ERROR_OK && preg_match("/^\* $id FETCH \(UID (.*)\)/i", $response, $m)) { - $result = $m[1]; + return (int) $m[1]; } - return $result; + return null; } function fetchUIDs($mailbox, $message_set=null) @@ -1615,18 +1632,32 @@ class rcube_imap_generic function copy($messages, $from, $to) { if (empty($from) || empty($to)) { - return -1; + return false; } if (!$this->select($from)) { - return -1; + return false; } $result = $this->execute('UID COPY', array( $this->compressMessageSet($messages), $this->escape($to)), self::COMMAND_NORESPONSE); - return $result; + return ($result == self::ERROR_OK); + } + + function move($messages, $from, $to) + { + if (!$from || !$to) { + return false; + } + + $r = $this->copy($messages, $from, $to); + + if ($r) { + return $this->delete($from, $messages); + } + return $r; } // Don't be tempted to change $str to pass by reference to speed this up - it will slow it down by about @@ -1806,20 +1837,6 @@ class rcube_imap_generic return false; } - function move($messages, $from, $to) - { - if (!$from || !$to) { - return -1; - } - - $r = $this->copy($messages, $from, $to); - - if ($r==0) { - return $this->delete($from, $messages); - } - return $r; - } - /** * Returns list of mailboxes * |