From 52851464e0267795ffd688e3c769d9161011dba8 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 02 Oct 2008 13:48:29 -0400
Subject: [PATCH] - Fix race conditions when changing mailbox (set some env variables only when needed - no action or action==list)

---
 program/include/rcube_user.php |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index 1d07085..00f5cd7 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -31,7 +31,7 @@
 {
   public $ID = null;
   public $data = null;
-  public $language = 'en_US';
+  public $language = null;
   
   private $db = null;
   
@@ -59,17 +59,7 @@
     }
   }
 
-  /**
-   * PHP 4 object constructor
-   *
-   * @see  rcube_user::__construct
-   */
-  function rcube_user($id = null, $sql_arr = null)
-  {
-    $this->__construct($id, $sql_arr);
-  }
-  
-  
+
   /**
    * Build a user name string (as e-mail address)
    *
@@ -88,10 +78,13 @@
    */
   function get_prefs()
   {
+    if (!empty($this->language))
+      $prefs = array('language' => $this->language);
+    
     if ($this->ID && $this->data['preferences'])
-      return array('language' => $this->language) + unserialize($this->data['preferences']);
-    else
-      return array();
+      $prefs += (array)unserialize($this->data['preferences']);
+    
+    return $prefs;
   }
   
   
@@ -164,7 +157,7 @@
        WHERE  del<>1
        AND    user_id=?
        $sql_add
-       ORDER BY ".$this->db->quoteIdentifier('standard')." DESC, name ASC",
+       ORDER BY ".$this->db->quoteIdentifier('standard')." DESC, name ASC, identity_id ASC",
       $this->ID);
     
     return $sql_result;
@@ -380,9 +373,9 @@
       $user_name = $user != $user_email ? $user : '';
 
       // try to resolve the e-mail address from the virtuser table
-      if ($virtuser_query = $rcmail->config->get('virtuser_query') &&
-          ($sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($user), $virtuser_query))) &&
-          ($dbh->num_rows() > 0))
+      if (($virtuser_query = $rcmail->config->get('virtuser_query'))
+    	&& ($sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($user), $virtuser_query)))
+	&& ($dbh->num_rows() > 0))
       {
         while ($sql_arr = $dbh->fetch_array($sql_result))
         {

--
Gitblit v1.9.1