From 85e65c3c7672d0e56ada988a047f0f602ba0c964 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 11 Jun 2013 03:41:02 -0400
Subject: [PATCH] Improvements to PR merge "add option show_real_foldernames"

---
 CHANGELOG                             |    1 +
 program/include/rcmail.php            |   19 ++++++++-----------
 program/localization/en_US/labels.inc |    1 +
 config/main.inc.php.dist              |    2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index bcc6e20..a4aff5c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Add option show_real_foldernames to disable localization of special folders
 - Fix zipdownload plugin issue with filenames charset (#1489156)
 - Fix database cache expunge issues (#1489149)
 - Fix date format issues on MS SQL Server (#1488918)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 1091b87..84a0a7a 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -481,7 +481,7 @@
 // NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
 $rcmail_config['default_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
 
-// Disable localization of the four default folder names listed above
+// Disable localization of the default folder names listed above
 $rcmail_config['show_real_foldernames'] = false;
 
 // automatically create the above listed default folders on first login
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 17c95d7..22d0811 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -1325,9 +1325,7 @@
         $realnames = (bool)$attrib['realnames'];
         $msgcounts = $this->storage->get_cache('messagecount');
         $collapsed = $this->config->get('collapsed_folders');
-
-        if ($this->config->get('show_real_foldernames'))
-            $realnames = true;
+        $realnames = $this->config->get('show_real_foldernames');
 
         $out = '';
         foreach ($arrFolders as $folder) {
@@ -1484,8 +1482,10 @@
      */
     public function localize_foldername($name, $with_path = true)
     {
+        $realnames = $this->config->get('show_real_foldernames');
+
         // try to localize path of the folder
-        if ($with_path) {
+        if ($with_path && !$realnames) {
             $storage   = $this->get_storage();
             $delimiter = $storage->get_hierarchy_delimiter();
             $path      = explode($delimiter, $name);
@@ -1494,8 +1494,7 @@
             if ($count > 1) {
                 for ($i = 0; $i < $count; $i++) {
                     $folder = implode($delimiter, array_slice($path, 0, -$i));
-                    if (!$this->config->get('show_real_foldernames') &&
-                        ($folder_class = $this->folder_classname($folder))) {
+                    if ($folder_class = $this->folder_classname($folder)) {
                         $name = implode($delimiter, array_slice($path, $count - $i));
                         return $this->gettext($folder_class) . $delimiter . rcube_charset::convert($name, 'UTF7-IMAP');
                     }
@@ -1503,13 +1502,11 @@
             }
         }
 
-        if (!$this->config->get('show_real_foldernames') &&
-            ($folder_class = $this->folder_classname($name))) {
+        if (!$realnames && ($folder_class = $this->folder_classname($name))) {
             return $this->gettext($folder_class);
         }
-        else {
-            return rcube_charset::convert($name, 'UTF7-IMAP');
-        }
+
+        return rcube_charset::convert($name, 'UTF7-IMAP');
     }
 
 
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 8a8fa2c..d8e5173 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -37,6 +37,7 @@
 $labels['sent']   = 'Sent';
 $labels['trash']  = 'Trash';
 $labels['junk']   = 'Junk';
+$labels['show_real_foldernames'] = 'Show real names for special folders';
 
 // message listing
 $labels['subject'] = 'Subject';

--
Gitblit v1.9.1