From 84c90a821664cda43590cfd9df95315c6f88fff9 Mon Sep 17 00:00:00 2001 From: alec Date: Thu, 28 Jul 2011 07:31:16 +0000 Subject: - Fixed bug where wrong folders hierarchy was displayed on folders listing git-svn-id: https://svn.roundcube.net/trunk@4983 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/managesieve/Changelog | 3 ++ plugins/managesieve/managesieve.php | 100 ++++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 44 deletions(-) (limited to 'plugins') diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 6cc5159be..4472ccf21 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,5 +1,8 @@ +* version 4.3 [2011-07-28] +----------------------------------------------------------- - Fixed handling of error in Net_Sieve::listScripts() - Fixed handling of REFERRAL responses (http://pear.php.net/bugs/bug.php?id=17107) +- Fixed bug where wrong folders hierarchy was displayed on folders listing * version 4.2 [2011-05-24] ----------------------------------------------------------- diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 7cd210ecf..8ee3b3bde 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -7,11 +7,26 @@ * It's clickable interface which operates on text scripts and communicates * with server using managesieve protocol. Adds Filters tab in Settings. * - * @version 4.2 - * @author Aleksander 'A.L.E.C' Machniak + * @version 4.3 + * @author Aleksander Machniak * * Configuration (see config.inc.php.dist) * + * Copyright (C) 2008-2011, The Roundcube Dev Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * * $Id$ */ @@ -490,7 +505,7 @@ class managesieve extends rcube_plugin case 'fileinto': case 'fileinto_copy': $mailbox = $this->strip_value($mailboxes[$idx]); - $this->form['actions'][$i]['target'] = $mailbox; + $this->form['actions'][$i]['target'] = $this->mod_mailbox($mailbox, 'in'); if ($type == 'fileinto_copy') { $type = 'fileinto'; $this->form['actions'][$i]['copy'] = true; @@ -1089,46 +1104,20 @@ class managesieve extends rcube_plugin $out .= ''; // mailbox select - $out .= ''; + $this->rc->imap_connect(); + $select = rcmail_mailbox_select(array( + 'realnames' => false, + 'maxlength' => 100, + 'id' => 'action_mailbox' . $id, + 'name' => '_action_mailbox[]', + 'style' => 'display:'.(!isset($action) || $action['type']=='fileinto' ? 'inline' : 'none') + )); + $out .= $select->show($mailbox); $out .= ''; // add/del buttons @@ -1174,11 +1163,6 @@ class managesieve extends rcube_plugin return ''; } - private function mbox_encode($text, $encoding) - { - return rcube_charset_convert($text, 'UTF7-IMAP', $encoding); - } - private function add_tip($id, $str, $error=false) { if ($error) @@ -1196,4 +1180,32 @@ class managesieve extends rcube_plugin $this->rc->output->add_script($script, 'foot'); } + /** + * Converts mailbox name from/to UTF7-IMAP from/to internal Sieve encoding + * with delimiter replacement. + * + * @param string $mailbox Mailbox name + * @param string $mode Conversion direction ('in'|'out') + * + * @return string Mailbox name + */ + private function mod_mailbox($mailbox, $mode = 'out') + { + $delimiter = $_SESSION['imap_delimiter']; + $replace_delimiter = $this->rc->config->get('managesieve_replace_delimiter'); + $mbox_encoding = $this->rc->config->get('managesieve_mbox_encoding', 'UTF7-IMAP'); + + if ($mode == 'out') { + $mailbox = rcube_charset_convert($mailbox, $mbox_encoding, 'UTF7-IMAP'); + if ($replace_delimiter && $replace_delimiter != $delimiter) + $mailbox = str_replace($replace_delimiter, $delimiter, $mailbox); + } + else { + $mailbox = rcube_charset_convert($mailbox, 'UTF7-IMAP', $mbox_encoding); + if ($replace_delimiter && $replace_delimiter != $delimiter) + $mailbox = str_replace($delimiter, $replace_delimiter, $mailbox); + } + + return $mailbox; + } } -- cgit v1.2.3