From 35a157ead933498b53a06df50fc909bb46216a8c Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 5 Dec 2016 20:21:08 +0100 Subject: [PATCH] Added category parsing --- php/composer.json | 8 +++++++- php/module.contact.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/php/composer.json b/php/composer.json index 303bfe5..8ec53e7 100644 --- a/php/composer.json +++ b/php/composer.json @@ -1,5 +1,11 @@ { + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/h44z/vcard" + } + ], "require": { - "jeroendesloovere/vcard": "1.2.*" + "jeroendesloovere/vcard": "dev-patchcategories" } } diff --git a/php/module.contact.php b/php/module.contact.php index 79ccf43..cf0897c 100644 --- a/php/module.contact.php +++ b/php/module.contact.php @@ -397,6 +397,11 @@ class ContactModule extends Module $vCard->addNote($notes); } + if (!empty($this->getProp($messageProps, "categories"))) { + $categories = array_map('trim', explode(';', trim($this->getProp($messageProps, "categories"), " ;"))); + $vCard->addCategories($categories); + } + $hasPicture = $this->getProp($messageProps, "has_picture"); if (!empty($hasPicture) && $hasPicture === true) { $attachNum = -1; @@ -921,6 +926,14 @@ class ContactModule extends Module if (isset($vCard->note)) { $properties["notes"] = $vCard->note; } + if (isset($vCard->categories) && count($vCard->categories) > 0) { + $categories = array(); + foreach ($vCard->categories as $category) { + $categories[] = $category; + } + + $properties["categories"] = $categories; + } if (isset($vCard->rawPhoto) || isset($vCard->photo)) { if (!is_writable(TMP_PATH . "/")) { error_log("Can not write to export tmp directory!");