alecpl
2010-10-29 93272ea91b3263acd883cac77986125e9a2ad8c6
- Use consistent results from some functions, code cleanup


2 files modified
84 ■■■■■ changed files
program/include/rcube_imap.php 11 ●●●● patch | view | raw | blame | history
program/include/rcube_imap_generic.php 73 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.php
@@ -2474,8 +2474,7 @@
        }
        // 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 @@
        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 @@
        }
        // 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 @@
        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);
program/include/rcube_imap_generic.php
@@ -1199,35 +1199,52 @@
        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 @@
    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
@@ -1804,20 +1835,6 @@
        }
        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;
    }
    /**