From: Jan Schneider Date: Mon, 17 Jan 2011 14:13:46 +0000 (+0100) Subject: Fix splitting up names when exporting to N properties of vCards. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3d4fa8ffc9ba4b7683ef80e8d8e99a67a11d28ce;p=horde.git Fix splitting up names when exporting to N properties of vCards. --- diff --git a/turba/docs/CHANGES b/turba/docs/CHANGES index b8bd31c15..d56148219 100644 --- a/turba/docs/CHANGES +++ b/turba/docs/CHANGES @@ -16,6 +16,7 @@ v3.0-git v2.3.6-cvs ---------- +[jan] Fix splitting up names when exporting to N properties of vCards. [jan] Only set the encoding parameter for binary data in vCards, if data is not empty (Bug #9413). [jan] Fix searching for fields matching an email address if using 'emails' diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index bedaeafeb..ec8ef1beb 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -1617,16 +1617,14 @@ class Turba_Driver implements Countable // No explicit firstname/lastname in data source: we have to guess. if (!isset($hash['lastname']) && isset($hash['name'])) { - $i = strpos($hash['name'], ','); - if (is_int($i)) { + if (($pos = strpos($hash['name'], ',')) !== false) { // Assume Last, First - $hash['lastname'] = Horde_String::substr($hash['name'], 0, $i); - $hash['firstname'] = trim(Horde_String::substr($hash['name'], $i + 1)); - } elseif (is_int(strpos($hash['name'], ' '))) { + $hash['lastname'] = Horde_String::substr($hash['name'], 0, $pos); + $hash['firstname'] = trim(Horde_String::substr($hash['name'], $pos + 1)); + } elseif (($pos = Horde_String::rpos($hash['name'], ' ')) !== false) { // Assume everything after last space as lastname - $i = strrpos($hash['name'], ' '); - $hash['lastname'] = trim(Horde_String::substr($hash['name'], $i + 1)); - $hash['firstname'] = Horde_String::substr($hash['name'], 0, $i); + $hash['lastname'] = trim(Horde_String::substr($hash['name'], $pos + 1)); + $hash['firstname'] = Horde_String::substr($hash['name'], 0, $pos); } else { $hash['lastname'] = $hash['name']; $hash['firstname'] = '';