summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-05-16 16:04:02 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-05-16 16:04:02 (GMT)
commit1eac719d26a9a3443b2c00abc146a869e0801fe1 (patch)
tree6733aef2ab9e7ee5066562bbf5e1669310c57d9c
parent505413660949104a8fea51b0f36f5074999ac38c (diff)
downloadiRony-1eac719d26a9a3443b2c00abc146a869e0801fe1.tar.gz
Fix converting vcard data from CardDAV clients to internal format
-rw-r--r--lib/Kolab/CardDAV/ContactsBackend.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Kolab/CardDAV/ContactsBackend.php b/lib/Kolab/CardDAV/ContactsBackend.php
index 08983de..35a1e3d 100644
--- a/lib/Kolab/CardDAV/ContactsBackend.php
+++ b/lib/Kolab/CardDAV/ContactsBackend.php
@@ -479,8 +479,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$vc->add('X-CHILDREN', join(',', (array)$contact['children']));
foreach ((array)$contact['email'] as $email) {
- // TODO: add types
- $vc->add('EMAIL', $email, array('type' => 'INTERNET'));
+ $vc->add('EMAIL', $email['address'], array('type' => rtrim('INTERNET,' . strtoupper($email['type']), ',')));
}
foreach ((array)$contact['phone'] as $phone) {
@@ -598,25 +597,24 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
break;
case 'EMAIL':
- $types = self::array_filter($prop->offsetGet('type'), 'internet,pref', true);
- // console(array_map('strtolower', $types));
- $contact['email'][] = $prop->value;
+ $types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
+ $contact['email'][] = array('address' => $prop->value, 'type' => strtolower($types[0] ?: 'other'));
break;
case 'URL':
- $types = self::array_filter($prop->offsetGet('type'), 'internet,pref', true);
+ $types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
$contact['website'][] = array('url' => $prop->value, 'type' => strtolower($types[0]));
break;
case 'TEL':
- $types = self::array_filter($prop->offsetGet('type'), 'internet,pref', true);
+ $types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
$type = strtolower($types[0]);
$contact['phone'][] = array('number' => $prop->value, 'type' => $phonetypemap[$type] ?: $type);
break;
case 'ADR':
$type = $prop->offsetGet('type');
- $adr = array('type' => strval($type));
+ $adr = array('type' => strtolower($type));
list(,, $adr['street'], $adr['locality'], $adr['region'], $adr['code'], $adr['country']) = $prop->getParts();
$contact['address'][] = $adr;
break;
@@ -706,9 +704,11 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$result = array();
$keep = array_flip((array)$values);
- foreach ($arr as $key => $val) {
- if ($inverse != isset($keep[strtolower($val)])) {
- $result[$key] = $val;
+ if (!empty($arr)) {
+ foreach ($arr as $key => $val) {
+ if ($inverse != isset($keep[strtolower($val)])) {
+ $result[$key] = $val;
+ }
}
}