Clean empty values in contact data, fixes #267

This commit is contained in:
Aleksander Machniak (Kolab Systems) 2011-08-03 11:55:36 +02:00
parent ae4b2d6b51
commit 909d2c43a7

View file

@ -1124,7 +1124,7 @@ class rcube_kolab_contacts extends rcube_addressbook
$emails = $this->get_col_values('email', $contact, true);
$object['emails'] = join(', ', array_filter($emails));
// overwrite 'email' field
$object['email'] = '';
unset($object['email']);
foreach ($this->get_col_values('phone', $contact) as $type => $values) {
if ($this->phonetypemap[$type])
@ -1146,6 +1146,11 @@ class rcube_kolab_contacts extends rcube_addressbook
$updated = false;
$basekey = 'addr-' . $type . '-';
foreach ((array)$values as $adr) {
// skip empty address
$adr = array_filter($adr);
if (empty($adr))
continue;
// switch type if slot is already taken
if (isset($object[$basekey . 'type'])) {
$type = $type == 'home' ? 'business' : 'home';