Aleksander Machniak
2012-05-22 0a1dd5b073f0dfc42439ab168246ae0ae6921414
program/include/rcmail.php
@@ -1329,11 +1329,12 @@
        $attrib      = $hook['attribs'];
        if ($type == 'select') {
            $attrib['is_escaped'] = true;
            $select = new html_select($attrib);
            // add no-selection option
            if ($attrib['noselection']) {
                $select->add($rcmail->gettext($attrib['noselection']), '');
                $select->add(html::quote($rcmail->gettext($attrib['noselection'])), '');
            }
            $rcmail->render_folder_tree_select($a_mailboxes, $mbox_name, $attrib['maxlength'], $select, $attrib['realnames']);
@@ -1362,7 +1363,7 @@
     */
    public function folder_selector($p = array())
    {
        $p += array('maxlength' => 100, 'realnames' => false);
        $p += array('maxlength' => 100, 'realnames' => false, 'is_escaped' => true);
        $a_mailboxes = array();
        $storage = $this->get_storage();
@@ -1388,7 +1389,7 @@
        $select = new html_select($p);
        if ($p['noselection']) {
            $select->add($p['noselection'], '');
            $select->add(html::quote($p['noselection']), '');
        }
        $this->render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames'], 0, $p);
@@ -1579,7 +1580,7 @@
                }
            }
            $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']);
            $select->add(str_repeat(' ', $nestLevel*4) . html::quote($foldername), $folder['id']);
            if (!empty($folder['folders'])) {
                $out .= $this->render_folder_tree_select($folder['folders'], $mbox_name, $maxlength,
@@ -2011,4 +2012,35 @@
    {
        return $this->storage_connect();
    }
    /**
     * Connect to the mail storage server with stored session data
     *
     * @return bool True on success, False on error
     */
    public function storage_connect()
    {
        $storage = $this->get_storage();
        if ($_SESSION['storage_host'] && !$storage->is_connected()) {
            $host = $_SESSION['storage_host'];
            $user = $_SESSION['username'];
            $port = $_SESSION['storage_port'];
            $ssl  = $_SESSION['storage_ssl'];
            $pass = $this->decrypt($_SESSION['password']);
            if (!$storage->connect($host, $user, $pass, $port, $ssl)) {
                if (is_object($this->output)) {
                    $error = $storage->get_error_code() == -1 ? 'storageerror' : 'sessionerror';
                    $this->output->show_message($error, 'error');
                }
            }
            else {
                $this->set_storage_prop();
                return $storage->is_connected();
            }
        }
        return false;
    }
}