49 $hex = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F');
50 $lines = preg_split(
"/(\?:\r\n|\r|\n)/", $input);
52 $linebreak =
"=0D=0A";
57 for ($j = 0; $j < $num; $j++) {
59 $linlen = strlen($line);
61 for ($i = 0; $i < $linlen; $i++) {
62 $c = substr($line, $i, 1);
64 if (($dec == 32) && ($i == ($linlen - 1))) {
66 } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {
67 $h2 = floor($dec / 16);
68 $h1 = floor($dec % 16);
69 $c = $escape.$hex[
"$h2"].$hex[
"$h1"];
71 if ((strlen($newline) + strlen($c)) >= $line_max) {
72 $output .= $newline.$escape.$eol;
78 if ($j < count($lines) - 1) {
79 $output .= $linebreak;
104 public $encoding =
"CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE";
121 $key .=
";VALUE=uri";
123 $this->properties[$key] =
'tel:'.$number;
138 $this->properties[
"PHOTO;MEDIATYPE=$type"] = $photo;
150 $this->properties[
"FN;".$this->encoding] =
encode($name);
164 public function setName($family =
"", $first =
"", $additional =
"", $prefix =
"", $suffix =
"")
168 $this->filename =
"$first%20$family.vcf";
169 if (empty($this->properties[
"FN"])) {
170 $this->
setFormattedName(trim(
"$prefix $first $additional $family $suffix"));
201 public function setAddress($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"", $label =
"")
209 $key .=
';LABEL="'.encode($label).
'"';
211 $key .=
";".$this->encoding;
233 public function setLabel($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"HOME")
236 if ($postoffice !=
"") {
237 $label .=
"$postoffice\r\n";
239 if ($extended !=
"") {
240 $label .=
"$extended\r\n";
243 $label .=
"$street\r\n";
249 $label .=
"$city\r\n";
252 $label .=
"$region\r\n";
254 if ($country !=
"") {
255 $country .=
"$country\r\n";
258 $this->properties[
"LABEL;$type;".$this->encoding] =
encode($label);
271 if ($type ==
"PREF") {
273 } elseif (!empty($type)) {
274 $key .=
";TYPE=".dol_strtolower($type);
276 $this->properties[$key] = $address;
287 $this->properties[
"NOTE;".$this->encoding] =
encode($note);
298 $this->properties[
"TITLE;".$this->encoding] =
encode($title);
310 $this->properties[
"ORG;".$this->encoding] =
encode($org);
322 $this->properties[
"PRODID"] =
encode($prodid);
334 $this->properties[
"UID"] =
encode($uid);
352 $this->properties[$key] = $url;
362 $text =
"BEGIN:VCARD\r\n";
363 $text .=
"VERSION:4.0\r\n";
365 foreach ($this->properties as $key => $value) {
366 $newkey = preg_replace(
'/(?<!QUOTED|UTF)-.*$/',
'', $key);
367 $text .= $newkey.
":".$value.
"\r\n";
369 $text .=
"REV:".date(
"Ymd").
"T".date(
"His").
"Z\r\n";
371 $text .=
"END:VCARD\r\n";
383 return $this->filename;
399 global $dolibarr_main_instance_unique_id;
401 $this->
setProdId(
'Dolibarr '.DOL_VERSION);
403 $this->
setUID(
'DOLIBARR-USERID-'.
dol_trunc(md5(
'vcard'.$dolibarr_main_instance_unique_id), 8,
'right',
'UTF-8', 1).
'-'.
$object->id);
410 $this->
setPhoto($mimetype, $urlphoto);
428 if (!empty(
$object->socialnetworks)) {
429 foreach (
$object->socialnetworks as $key => $val) {
434 if ($key ==
'linkedin') {
435 if (!preg_match(
'/^http/', $val)) {
436 $urlsn =
'https://www.'.$key.
'.com/company/'.urlencode($val);
440 } elseif ($key ==
'youtube') {
441 if (!preg_match(
'/^http/', $val)) {
442 $urlsn =
'https://www.'.$key.
'.com/user/'.urlencode($val);
447 if (!preg_match(
'/^http/', $val)) {
448 $urlsn =
'https://www.'.$key.
'.com/'.urlencode($val);
454 $this->properties[
"SOCIALPROFILE;TYPE=WORK-".$key] = $key.
':'.$urlsn;
489 if (is_object($company)) {
491 if ($company->typent_code !=
'TE_PRIVATE') {
492 $this->
setOrg($company->name);
495 $this->
setURL($company->url,
"");
497 if ($company->phone && $company->phone !=
$object->office_phone) {
500 if ($company->fax && $company->fax !=
$object->office_fax) {
503 if ($company->address || $company->town || $company->state || $company->zip || $company->country) {
504 $this->
setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK");
507 if ($company->email && $company->email !=
$object->email) {
508 $this->
setEmail($company->email,
"TYPE=WORK");
550 $outfilename = $outdir.
'/virtualcard_'.
$object->element.
'_'.
$object->id.
'.vcf';
552 file_put_contents($outfilename, $this->
getVCard());
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to build vCard files.
setEmail($address, $type="")
Add a e-mail address to this vCard.
setTitle($title)
mise en forme de la fonction
setPhoneNumber($number, $type="")
Format phone number.
setPhoto($type, $photo)
Format photo.
setBirthday($date)
Format the birth date.
setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME")
Address (old standard)
setUID($uid)
mise en forme du logiciel generateur
getFileName()
Return name of a file.
setOrg($org)
mise en forme de la societe
buildVCardString($object, $company, $langs, $urlphoto='', $outdir='')
Return a VCARD string See RFC https://datatracker.ietf.org/doc/html/rfc6350.
setProdId($prodid)
mise en forme du logiciel generateur
setFormattedName($name)
Format name.
setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="", $label="")
Address.
setName($family="", $first="", $additional="", $prefix="", $suffix="")
Format the name.
getVCard()
Return string of a vcard.
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.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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.