From 9df7e17043e241b5e3d1d4739ff6d24fdeecc205 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 21 Jun 2013 03:34:47 -0400
Subject: [PATCH] Disable workaround for http://bugs.php.net/bug.php?id=18556 if PHP 5.5 is detected

---
 program/include/rcmail.php |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index a7ddb1e..d430cd3 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -162,7 +162,7 @@
     setlocale(LC_ALL, $lang . '.utf8', $lang . '.UTF-8', 'en_US.utf8', 'en_US.UTF-8');
 
     // workaround for http://bugs.php.net/bug.php?id=18556
-    if (in_array($lang, array('tr_TR', 'ku', 'az_AZ'))) {
+    if (version_compare(PHP_VERSION, '5.5.0', '<') && in_array($lang, array('tr_TR', 'ku', 'az_AZ'))) {
       setlocale(LC_CTYPE, 'en_US.utf8', 'en_US.UTF-8');
     }
   }
@@ -228,6 +228,11 @@
     }
 
     if (!$contacts) {
+      // there's no default, just return
+      if ($default) {
+        return null;
+      }
+
       self::raise_error(array(
         'code' => 700, 'type' => 'php',
         'file' => __FILE__, 'line' => __LINE__,
@@ -289,7 +294,7 @@
         $list[$id] = array(
           'id'       => $id,
           'name'     => html::quote($prop['name']),
-          'groups'   => is_array($prop['groups']),
+          'groups'   => !empty($prop['groups']) || !empty($prop['group_filters']),
           'readonly' => !$prop['writable'],
           'hidden'   => $prop['hidden'],
           'autocomplete' => in_array($id, $autocomplete)
@@ -742,11 +747,6 @@
     foreach ($this->address_books as $book) {
       if (is_object($book) && is_a($book, 'rcube_addressbook'))
         $book->close();
-    }
-
-    // before closing the database connection, write session data
-    if ($_SERVER['REMOTE_ADDR'] && is_object($this->session)) {
-      $this->session->write_close();
     }
 
     // write performance stats to logs/console
@@ -1325,6 +1325,7 @@
         $realnames = (bool)$attrib['realnames'];
         $msgcounts = $this->storage->get_cache('messagecount');
         $collapsed = $this->config->get('collapsed_folders');
+        $realnames = $this->config->get('show_real_foldernames');
 
         $out = '';
         foreach ($arrFolders as $folder) {
@@ -1481,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);
@@ -1499,12 +1502,11 @@
             }
         }
 
-        if ($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');
     }
 
 
@@ -1559,11 +1561,7 @@
         $quota_result = (array) $quota;
         $quota_result['type'] = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
 
-        if (!$quota['total'] && $this->config->get('quota_zero_as_unlimited')) {
-            $quota_result['title']   = $this->gettext('unlimited');
-            $quota_result['percent'] = 0;
-        }
-        else if ($quota['total']) {
+        if ($quota['total'] > 0) {
             if (!isset($quota['percent'])) {
                 $quota_result['percent'] = min(100, round(($quota['used']/max(1,$quota['total']))*100));
             }
@@ -1582,7 +1580,8 @@
             }
         }
         else {
-            $quota_result['title']   = $this->gettext('unknown');
+            $unlimited               = $this->config->get('quota_zero_as_unlimited');
+            $quota_result['title']   = $this->gettext($unlimited ? 'unlimited' : 'unknown');
             $quota_result['percent'] = 0;
         }
 
@@ -1761,7 +1760,8 @@
     public function upload_init()
     {
         // Enable upload progress bar
-        if (($seconds = $this->config->get('upload_progress')) && ini_get('apc.rfc1867')) {
+        $rfc1867 = filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN);
+        if ($rfc1867 && ($seconds = $this->config->get('upload_progress'))) {
             if ($field_name = ini_get('apc.rfc1867_name')) {
                 $this->output->set_env('upload_progress_name', $field_name);
                 $this->output->set_env('upload_progress_time', (int) $seconds);

--
Gitblit v1.9.1