From faca46de50a9f167b350987bb510d4a84e671118 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 12 Oct 2009 16:21:15 -0600 Subject: [PATCH] Bug #8554: Don't use translated folder prefixes in rename dialog --- imp/docs/CHANGES | 1 + imp/folders.php | 12 ++++++++++-- imp/js/folders.js | 2 +- imp/lib/IMP.php | 11 ++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index d8c1aaca1..02ba03671 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -104,6 +104,7 @@ v5.0-git v4.3.6-cvs ---------- +[mms] Don't use translated folder prefixes in rename dialog (Bug #8554). [jan] Add hook to retrieve public S/MIME and PGP keys. diff --git a/imp/folders.php b/imp/folders.php index 4c4a7a299..756379f62 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -351,11 +351,19 @@ list($raw_rows, $newmsgs) = $imaptree->build(); /* Build the list of display names. */ reset($raw_rows); -while (list(,$r) = each($raw_rows)) { +$displayNames = $fullNames = array(); +while (list($k, $r) = each($raw_rows)) { $displayNames[] = $r['display']; + + $tmp = IMP::displayFolder($r['value'], true); + if ($tmp != $r['display']) { + $fullNames[$k] = $tmp; + } } + Horde::addInlineScript(array( - 'ImpFolders.displayNames = ' . Horde_Serialize::serialize($displayNames, Horde_Serialize::JSON, $charset) + 'ImpFolders.displayNames = ' . Horde_Serialize::serialize($displayNames, Horde_Serialize::JSON, $charset), + 'ImpFolders.fullNames = ' . Horde_Serialize::serialize($fullNames, Horde_Serialize::JSON, $charset) )); /* Prepare the header template. */ diff --git a/imp/js/folders.js b/imp/js/folders.js index 0537b5b8a..81d6594f9 100644 --- a/imp/js/folders.js +++ b/imp/js/folders.js @@ -136,7 +136,7 @@ var ImpFolders = { if (IMP.conf.fixed_folders.indexOf(this.displayNames[j]) != -1) { window.alert(IMP.text.folders_no_rename + ' ' + this.displayNames[j]); } else { - var tmp = window.prompt(IMP.text.folders_rename1 + ' ' + this.displayNames[j] + "\n" + IMP.text.folders_rename2, this.displayNames[j]); + var tmp = window.prompt(IMP.text.folders_rename1 + ' ' + this.displayNames[j] + "\n" + IMP.text.folders_rename2, this.fullNames[j] ? this.fullNames[j] : this.displayNames[j]); if (tmp) { newnames += tmp + "\n"; oldnames += f.value + "\n"; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 170779641..4d3a76e43 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -430,17 +430,18 @@ class IMP * strip that prefix out. Additionally, translate prefix text if this * is one of the folders with special meaning. * - * @param string $folder The folder name to display (UTF7-IMAP). + * @param string $folder The folder name to display (UTF7-IMAP). + * @param boolean $notranslate Do not translate the folder prefix. * * @return string The folder, with any prefix gone/translated. */ - static public function displayFolder($folder) + static public function displayFolder($folder, $notranslate = false) { global $prefs; $cache = &self::$_displaycache; - if (isset($cache[$folder])) { + if (!$notranslate && isset($cache[$folder])) { return $cache[$folder]; } @@ -466,6 +467,10 @@ class IMP $out = $folder; }; + if ($notranslate) { + return $out; + } + foreach ($sub_array as $key => $val) { if (stripos($out, $key) === 0) { $len = strlen($key); -- 2.11.0