From 8bed5e0151eb375e2d2dc91e4e6c6d5aa62daa5c Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 19 Jul 2015 05:06:48 -0400
Subject: [PATCH] Fix regression where compose editor mode was set incorrectly

---
 program/lib/Roundcube/rcube_addressbook.php |   49 +++++++++++++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php
index 69f8bf9..a08baf7 100644
--- a/program/lib/Roundcube/rcube_addressbook.php
+++ b/program/lib/Roundcube/rcube_addressbook.php
@@ -1,6 +1,6 @@
 <?php
 
-/*
+/**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2006-2013, The Roundcube Dev Team                       |
@@ -16,7 +16,6 @@
  +-----------------------------------------------------------------------+
 */
 
-
 /**
  * Abstract skeleton of an address book/repository
  *
@@ -26,27 +25,32 @@
 abstract class rcube_addressbook
 {
     /** constants for error reporting **/
-    const ERROR_READ_ONLY = 1;
+    const ERROR_READ_ONLY     = 1;
     const ERROR_NO_CONNECTION = 2;
-    const ERROR_VALIDATE = 3;
-    const ERROR_SAVING = 4;
-    const ERROR_SEARCH = 5;
+    const ERROR_VALIDATE      = 3;
+    const ERROR_SAVING        = 4;
+    const ERROR_SEARCH        = 5;
 
     /** public properties (mandatory) */
     public $primary_key;
-    public $groups = false;
+    public $groups        = false;
     public $export_groups = true;
-    public $readonly = true;
-    public $searchonly = false;
-    public $undelete = false;
-    public $ready = false;
-    public $group_id = null;
-    public $list_page = 1;
-    public $page_size = 10;
-    public $sort_col = 'name';
-    public $sort_order = 'ASC';
-    public $coltypes = array('name' => array('limit'=>1), 'firstname' => array('limit'=>1), 'surname' => array('limit'=>1), 'email' => array('limit'=>1));
-    public $date_cols = array();
+    public $readonly      = true;
+    public $searchonly    = false;
+    public $undelete      = false;
+    public $ready         = false;
+    public $group_id      = null;
+    public $list_page     = 1;
+    public $page_size     = 10;
+    public $sort_col      = 'name';
+    public $sort_order    = 'ASC';
+    public $date_cols     = array();
+    public $coltypes      = array(
+        'name'      => array('limit'=>1),
+        'firstname' => array('limit'=>1),
+        'surname'   => array('limit'=>1),
+        'email'     => array('limit'=>1)
+    );
 
     protected $error;
 
@@ -594,6 +598,13 @@
                 switch ($key) {
                 case 'name':
                     $value = $name ?: self::compose_list_name($contact);
+
+                    // If name(s) are undefined compose_list_name() may return an email address
+                    // here we prevent from returning the same name and email
+                    if ($name === $email && strpos($result, '{email}') !== false) {
+                        $value = '';
+                    }
+
                     break;
 
                 case 'email':
@@ -678,6 +689,4 @@
 
         return false;
     }
-
 }
-

--
Gitblit v1.9.1