From 3e12a8ab2178506f8906e3039e327b93676b8a45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2023 19:13:59 +0100 Subject: [PATCH] Debug vcard v4 --- htdocs/core/class/vcard.class.php | 11 ++++++++--- htdocs/public/users/view.php | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index eb6c0eab743..8a62c0aea5e 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -353,7 +353,7 @@ class vCard $text .= "VERSION:4.0\r\n"; // With V4, all encoding are UTF-8 //$text.= "VERSION:2.1\r\n"; foreach ($this->properties as $key => $value) { - $text .= "$key:$value\r\n"; + $text .= $key.":".$value."\r\n"; } $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; //$text .= "MAILER: Dolibarr\r\n"; @@ -374,7 +374,7 @@ class vCard /** * Return a VCARD string * - * @param Object $object Object + * @param Object $object Object (User, Contact) * @param Societe $company Company * @param Translate $langs Lang object * @return string String @@ -403,8 +403,13 @@ class vCard $this->setNote($object->note_public); $this->setTitle($object->job); - if ($company->id > 0) { + // For user, type=home + // For contact, this is not defined + $this->setURL($object->url, "TYPE=HOME"); + + if (is_object($company)) { $this->setURL($company->url, "TYPE=WORK"); + if (!$object->office_phone) { $this->setPhoneNumber($company->phone, "TYPE=WORK,VOICE"); } diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php index 511e7b93604..ba1a6dd0908 100644 --- a/htdocs/public/users/view.php +++ b/htdocs/public/users/view.php @@ -96,6 +96,7 @@ $company = $mysoc; if ($mode == 'vcard') { // We create VCard $v = new vCard(); + $output = $v->buildVCardString($object, $company, $langs); $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"