48 $hex = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F');
49 $lines = preg_split(
"/(\?:\r\n|\r|\n)/", $input);
51 $linebreak =
"=0D=0A";
56 for ($j = 0; $j < $num; $j++) {
58 $linlen = strlen($line);
60 for ($i = 0; $i < $linlen; $i++) {
61 $c = substr($line, $i, 1);
63 if (($dec == 32) && ($i == ($linlen - 1))) {
65 } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {
66 $h2 = floor($dec / 16);
67 $h1 = floor($dec % 16);
68 $c = $escape.$hex[
"$h2"].$hex[
"$h1"];
70 if ((strlen($newline) + strlen($c)) >= $line_max) {
71 $output .= $newline.$escape.$eol;
77 if ($j < count($lines) - 1) {
78 $output .= $linebreak;
103 public $encoding =
"ENCODING=QUOTED-PRINTABLE";
120 $key .=
";VALUE=uri";
122 $this->properties[$key] =
'tel:'.$number;
137 $this->properties[
"PHOTO;MEDIATYPE=$type"] = $photo;
149 $this->properties[
"FN;".$this->encoding] =
encode($name);
162 public function setName($family =
"", $first =
"", $additional =
"", $prefix =
"", $suffix =
"")
166 $this->filename =
"$first%20$family.vcf";
167 if (empty($this->properties[
"FN"])) {
168 $this->
setFormattedName(trim(
"$prefix $first $additional $family $suffix"));
199 public function setAddress($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"", $label =
"")
207 $key .=
';LABEL="'.encode($label).
'"';
209 $key .=
";".$this->encoding;
231 public function setLabel($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"HOME")
234 if ($postoffice !=
"") {
235 $label .=
"$postoffice\r\n";
237 if ($extended !=
"") {
238 $label .=
"$extended\r\n";
241 $label .=
"$street\r\n";
247 $label .=
"$city\r\n";
250 $label .=
"$region\r\n";
252 if ($country !=
"") {
253 $country .=
"$country\r\n";
256 $this->properties[
"LABEL;$type;".$this->encoding] =
encode($label);
269 if ($type ==
"PREF") {
271 } elseif (!empty($type)) {
272 $key .=
";TYPE=".dol_strtolower($type);
274 $this->properties[$key] = $address;
285 $this->properties[
"NOTE;".$this->encoding] =
encode($note);
296 $this->properties[
"TITLE;".$this->encoding] =
encode($title);
308 $this->properties[
"ORG;".$this->encoding] =
encode($org);
320 $this->properties[
"PRODID"] =
encode($prodid);
332 $this->properties[
"UID"] =
encode($uid);
350 $this->properties[$key] = $url;
360 $text =
"BEGIN:VCARD\r\n";
361 $text .=
"VERSION:4.0\r\n";
363 foreach ($this->properties as $key => $value) {
364 $newkey = preg_replace(
'/-.*$/',
'', $key);
365 $text .= $newkey.
":".$value.
"\r\n";
367 $text .=
"REV:".date(
"Ymd").
"T".date(
"His").
"Z\r\n";
369 $text .=
"END:VCARD\r\n";
380 return $this->filename;
395 global $dolibarr_main_instance_unique_id;
397 $this->
setProdId(
'Dolibarr '.DOL_VERSION);
399 $this->setUid(
'DOLIBARR-USERID-'.
dol_trunc(md5(
'vcard'.$dolibarr_main_instance_unique_id), 8,
'right',
'UTF-8', 1).
'-'.$object->id);
400 $this->
setName($object->lastname, $object->firstname,
"", $object->civility_code,
"");
406 $this->
setPhoto($mimetype, $urlphoto);
410 if ($object->office_phone) {
417 if ($object->user_mobile) {
420 if ($object->office_fax) {
424 if (!empty($object->socialnetworks)) {
425 foreach ($object->socialnetworks as $key => $val) {
430 if ($key ==
'linkedin') {
431 if (!preg_match(
'/^http/', $val)) {
432 $urlsn =
'https://www.'.$key.
'.com/company/'.urlencode($val);
436 } elseif ($key ==
'youtube') {
437 if (!preg_match(
'/^http/', $val)) {
438 $urlsn =
'https://www.'.$key.
'.com/user/'.urlencode($val);
443 if (!preg_match(
'/^http/', $val)) {
444 $urlsn =
'https://www.'.$key.
'.com/'.urlencode($val);
450 $this->properties[
"SOCIALPROFILE;TYPE=WORK-".$key] = $key.
':'.$urlsn;
455 $country = $object->country_code ? $object->country :
'';
457 if ($object->address || $object->town || $object->state || $object->zip || $object->country) {
458 $this->
setAddress(
"",
"", $object->address, $object->town, $object->state, $object->zip, $country,
"");
462 if ($object->email) {
463 $this->
setEmail($object->email,
"TYPE=WORK");
469 if ($object->note_public) {
470 $this->
setNote($object->note_public);
478 if (!empty($object->url)) {
479 $this->
setURL($object->url,
"");
482 if (is_object($company)) {
484 if ($company->typent_code !=
'TE_PRIVATE') {
485 $this->
setOrg($company->name);
488 $this->
setURL($company->url,
"");
490 if ($company->phone && $company->phone != $object->office_phone) {
493 if ($company->fax && $company->fax != $object->office_fax) {
496 if ($company->address || $company->town || $company->state || $company->zip || $company->country) {
497 $this->
setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK");
500 if ($company->email && $company->email != $object->email) {
501 $this->
setEmail($company->email,
"TYPE=WORK");
536 if ($object->birth) {
Class to buld vCard files.
setEmail($address, $type="")
Add a e-mail address to this vCard.
setTitle($title)
mise en forme de la fonction
setPhoneNumber($number, $type="")
mise en forme du numero de telephone
setPhoto($type, $photo)
mise en forme de la photo warning NON TESTE !
setBirthday($date)
mise en forme de l'anniversaire
setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME")
Address (old standard)
setUID($uid)
mise en forme du logiciel generateur
getFileName()
permet d'obtenir le nom de fichier
setOrg($org)
mise en forme de la societe
setProdId($prodid)
mise en forme du logiciel generateur
setFormattedName($name)
mise en forme du nom formate
setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="", $label="")
Address.
setName($family="", $first="", $additional="", $prefix="", $suffix="")
mise en forme du nom complet
getVCard()
permet d'obtenir une vcard
buildVCardString($object, $company, $langs, $urlphoto='')
Return a VCARD string See RFC https://datatracker.ietf.org/doc/html/rfc6350.
setNote($note)
mise en forme de la note
setURL($url, $type="")
mise en forme de l'url
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
encode($string)
Encode a string for vCard.
dol_quoted_printable_encode($input, $line_max=76)
Taken from php documentation comments No more used.