From bcfb008dce4ee5f0775bdecb9b5b4e7cfcbafdad Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 13 Aug 2014 15:54:52 +0200 Subject: [PATCH] Add support for some Vcard 4.0 contact properties --- plugins/libkolab/lib/kolab_format_contact.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php index 63efe9ae..806a8197 100644 --- a/plugins/libkolab/lib/kolab_format_contact.php +++ b/plugins/libkolab/lib/kolab_format_contact.php @@ -203,6 +203,8 @@ class kolab_format_contact extends kolab_format $this->obj->setNote($object['notes']); if (isset($object['freebusyurl'])) $this->obj->setFreeBusyUrl($object['freebusyurl']); + if (isset($object['lang'])) + $this->obj->setLanguages(self::array2vector($object['lang'])); if (isset($object['birthday'])) $this->obj->setBDay(self::get_datetime($object['birthday'], false, true)); if (isset($object['anniversary'])) @@ -227,6 +229,12 @@ class kolab_format_contact extends kolab_format } } } + // add other relateds + if (is_array($object['related'])) { + foreach ($object['related'] as $value) { + $rels->push(new Related(Related::Text, $value)); + } + } $this->obj->setRelateds($rels); // insert/replace crypto keys @@ -346,6 +354,7 @@ class kolab_format_contact extends kolab_format $object['notes'] = $this->obj->note(); $object['freebusyurl'] = $this->obj->freeBusyUrl(); + $object['lang'] = self::vector2array($this->obj->languages()); if ($bday = self::php_datetime($this->obj->bDay())) $object['birthday'] = $bday; @@ -363,7 +372,7 @@ class kolab_format_contact extends kolab_format $object['photo'] = $photo_name; // relateds -> spouse, children - $this->read_relateds($this->obj->relateds(), $object); + $this->read_relateds($this->obj->relateds(), $object, 'related'); // crypto settings: currently only key values are supported $keys = $this->obj->keys(); @@ -446,7 +455,7 @@ class kolab_format_contact extends kolab_format /** * Helper method to map contents of a Related vector to the contact data object */ - private function read_relateds($rels, &$object) + private function read_relateds($rels, &$object, $catchall = null) { $typemap = array_flip($this->relatedmap); @@ -455,13 +464,19 @@ class kolab_format_contact extends kolab_format if ($rel->type() != Related::Text) // we can't handle UID relations yet continue; + $known = false; $types = $rel->relationTypes(); foreach ($typemap as $t => $field) { if ($types & $t) { $object[$field][] = $rel->text(); + $known = true; break; } } + + if (!$known && $catchall) { + $object[$catchall][] = $rel->text(); + } } } }