Skip to content

Commit

Permalink
Only set the hash values is we have an entry in the map.
Browse files Browse the repository at this point in the history
Part of Bug #14301: Part of the fix for dealing with various sync
issues when incoming contact has TYPE attributes, but driver is
configured with only a single email field. This one is need for being
able to replace existing values.
  • Loading branch information
mrubinsk committed Aug 19, 2016
1 parent 5cec8e3 commit 9f14291
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions turba/lib/Driver.php
Expand Up @@ -2129,8 +2129,11 @@ protected function _hasValEnum($valEnum, $type)
*/
public function toHash(Horde_Icalendar_Vcard $vcard)
{
global $attributes;

$hash = array();
$attr = $vcard->getAllAttributes();

foreach ($attr as $item) {
switch ($item['name']) {
case 'UID':
Expand Down Expand Up @@ -2384,12 +2387,14 @@ public function toHash(Horde_Icalendar_Vcard $vcard)
case 'EMAIL':
$email_set = false;
if (isset($item['params']['HOME']) &&
!empty($this->map['homeEmail']) &&
(!isset($hash['homeEmail']) ||
isset($item['params']['PREF']))) {
$e = Horde_Icalendar_Vcard::getBareEmail($item['value']);
$hash['homeEmail'] = $e ? $e : '';
$email_set = true;
} elseif (isset($item['params']['WORK']) &&
!empty($this->map['workEmail']) &&
(!isset($hash['workEmail']) ||
isset($item['params']['PREF']))) {
$e = Horde_Icalendar_Vcard::getBareEmail($item['value']);
Expand All @@ -2403,12 +2408,14 @@ public function toHash(Horde_Icalendar_Vcard $vcard)
$type = Horde_String::upper($type);
}
if (in_array('HOME', $item['params']['TYPE']) &&
!empty($this->map['homeEmail']) &&
(!isset($hash['homeEmail']) ||
in_array('PREF', $item['params']['TYPE']))) {
$e = Horde_Icalendar_Vcard::getBareEmail($item['value']);
$hash['homeEmail'] = $e ? $e : '';
$email_set = true;
} elseif (in_array('WORK', $item['params']['TYPE']) &&
!empty($this->map['workEmail']) &&
(!isset($hash['workEmail']) ||
in_array('PREF', $item['params']['TYPE']))) {
$e = Horde_Icalendar_Vcard::getBareEmail($item['value']);
Expand Down

0 comments on commit 9f14291

Please sign in to comment.