From 445a4ca04dfcd255f9d89ee76757b04c2d87bbfc Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 13 May 2011 13:51:28 -0400
Subject: [PATCH] Fix empty name in search results and error when creating a new contact

---
 program/steps/addressbook/func.inc |    2 +-
 program/include/rcube_contacts.php |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index 8abc763..e7c078f 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -200,10 +200,13 @@
                 $sql_arr = $this->convert_db_data($sql_arr);
             else
                 $sql_arr['email'] = preg_split('/,\s*/', $sql_arr['email']);
-            
+
             // make sure we have a name to display
-            if (empty($sql_arr['name']))
+            if (empty($sql_arr['name'])) {
+                if (empty($sql_arr['email']))
+                  $sql_arr['email'] = $this->get_col_values('email', $sql_arr, true);
                 $sql_arr['name'] = $sql_arr['email'][0];
+            }
 
             $this->result->add($sql_arr);
         }
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index c361087..8b4a9f1 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -348,7 +348,7 @@
             $content = '';
 
             // unset display name if it is composed from name parts (same composition function as in save.inc)
-            if ($record['name'] == rcube_addressbook::compose_display_name(array('name' => '') + $record))
+            if ($record['name'] == rcube_addressbook::compose_display_name(array('name' => '') + (array)$record))
               unset($record['name']);
 
             // group fields

--
Gitblit v1.9.1