Aleksander Machniak
2012-08-29 10562d8a7760eae6b6cb22aa336605e09c7a8bce
Keep current folder context when fetching message parts,
to make sure that proper folder is used in case when
current folder has been changed in meantime.
2 files modified
28 ■■■■ changed files
program/include/rcube_message.php 26 ●●●● patch | view | raw | blame | history
program/include/rcube_storage.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_message.php
@@ -52,7 +52,8 @@
    private $opt = array();
    private $parse_alternative = false;
    public $uid = null;
    public $uid;
    public $folder;
    public $headers;
    public $parts = array();
    public $mime_parts = array();
@@ -68,16 +69,21 @@
     *
     * Provide a uid, and parse message structure.
     *
     * @param string $uid The message UID.
     * @param string $uid    The message UID.
     * @param string $folder Folder name
     *
     * @see self::$app, self::$storage, self::$opt, self::$parts
     */
    function __construct($uid)
    function __construct($uid, $folder = null)
    {
        $this->uid  = $uid;
        $this->app  = rcube::get_instance();
        $this->storage = $this->app->get_storage();
        $this->folder  = strlen($folder) ? $folder : $this->storage->get_folder();
        $this->storage->set_options(array('all_headers' => true));
        // Set current folder
        $this->storage->set_folder($this->folder);
        $this->headers = $this->storage->get_message($uid);
@@ -179,10 +185,12 @@
                }
                return $fp ? true : $part->body;
            }
            // get from IMAP
            $this->storage->set_folder($this->folder);
            return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp, $skip_charset_conv);
        } else
            return null;
        }
    }
@@ -637,8 +645,10 @@
    function tnef_decode(&$part)
    {
        // @TODO: attachment may be huge, hadle it via file
        if (!isset($part->body))
        if (!isset($part->body)) {
            $this->storage->set_folder($this->folder);
            $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part);
        }
        $parts = array();
        $tnef = new tnef_decoder;
@@ -673,8 +683,10 @@
    function uu_decode(&$part)
    {
        // @TODO: messages may be huge, hadle body via file
        if (!isset($part->body))
        if (!isset($part->body)) {
            $this->storage->set_folder($this->folder);
            $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part);
        }
        $parts = array();
        // FIXME: line length is max.65?
program/include/rcube_storage.php
@@ -195,7 +195,7 @@
     */
    public function set_folder($folder)
    {
        if ($this->folder == $folder) {
        if ($this->folder === $folder) {
            return;
        }