From 52877803f86c4f1b4e8a40b9a53b40586f653f2f Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 02 Jun 2012 10:59:01 -0400
Subject: [PATCH] Merge pull request #12 from mrhein/master

---
 program/steps/addressbook/func.inc |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index eb8a0e5..80d89b0 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -17,9 +17,6 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 $SEARCH_MODS_DEFAULT = array('name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1);
@@ -203,7 +200,7 @@
             'rel' => '%s',
             'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
 
-    $sources = (array) $OUTPUT->env['address_sources'];
+    $sources = (array) $OUTPUT->get_env('address_sources');
     reset($sources);
 
     // currently selected source
@@ -593,7 +590,12 @@
                         $composite = array(); $j = 0;
                         $template = $RCMAIL->config->get($col . '_template', '{'.join('} {', array_keys($colprop['childs'])).'}');
                         foreach ($colprop['childs'] as $childcol => $cp) {
-                            $childvalue = $val[$childcol] ? $val[$childcol] : $val[$j];
+                            if (!empty($val) && is_array($val)) {
+                                $childvalue = $val[$childcol] ? $val[$childcol] : $val[$j];
+                            }
+                            else {
+                                $childvalue = '';
+                            }
 
                             if ($edit_mode) {
                                 if ($colprop['subtypes'] || $colprop['limit'] != 1) $cp['array'] = true;
@@ -669,7 +671,7 @@
                 }
             }
 
-            if (!$content)
+            if (!$content && (!$edit_mode || !$select_add->_count))
                 continue;
 
             // also render add-field selector

--
Gitblit v1.9.1