50 $hex = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F');
51 $lines = preg_split(
"/(\?:\r\n|\r|\n)/", $input);
53 $linebreak =
"=0D=0A";
58 for ($j = 0; $j < $num; $j++) {
60 $linlen = strlen($line);
62 for ($i = 0; $i < $linlen; $i++) {
63 $c = substr($line, $i, 1);
65 if (($dec == 32) && ($i == ($linlen - 1))) {
67 } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {
68 $h2 = floor($dec / 16);
69 $h1 = floor($dec % 16);
70 $c = $escape.$hex[(int) $h2].$hex[(
int) $h1];
72 if ((strlen($newline) + strlen($c)) >= $line_max) {
73 $output .= $newline.$escape.$eol;
79 if ($j < count($lines) - 1) {
80 $output .= $linebreak;
105 public $encoding =
"ENCODING=QUOTED-PRINTABLE";
122 $key .=
";VALUE=uri";
124 $this->properties[$key] =
'tel:'.$number;
139 $this->properties[
"PHOTO;MEDIATYPE=$type"] = $photo;
151 $stringencoded =
encode($name);
152 $stringnotencoded = $name;
155 if ($stringencoded != $stringnotencoded) {
156 $key .=
";".$this->encoding;
159 $this->properties[$key] = $stringencoded;
173 public function setName($family =
"", $first =
"", $additional =
"", $prefix =
"", $suffix =
"")
178 $this->filename =
"$first%20$family.vcf";
180 if (empty($this->properties[
"FN"])) {
181 $this->
setFormattedName(trim(
"$prefix $first $additional $family $suffix"));
212 public function setAddress($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"", $label =
"")
220 $key .=
';LABEL="'.encode($label).
'"';
224 $stringnotencoded = $postoffice.
";".$extended.
";".$street.
";".$city.
";".$region.
";".$zip.
";".$country;
226 if ($stringencoded != $stringnotencoded) {
227 $key .=
";".$this->encoding;
230 $this->properties[$key] = $stringencoded;
251 public function setLabel($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"HOME")
254 if ($postoffice !=
"") {
255 $label .=
"$postoffice\r\n";
257 if ($extended !=
"") {
258 $label .=
"$extended\r\n";
261 $label .=
"$street\r\n";
267 $label .=
"$city\r\n";
270 $label .=
"$region\r\n";
272 if ($country !=
"") {
273 $country .=
"$country\r\n";
276 $this->properties[
"LABEL;$type;".$this->encoding] =
encode($label);
289 if ($type ===
"PREF") {
291 } elseif (!empty($type)) {
292 if (stripos($type,
'TYPE=') === 0) {
295 $key .=
";TYPE=".dol_strtolower($type);
298 $this->properties[$key] = $address;
309 $this->properties[
"NOTE;".$this->encoding] =
encode($note);
320 $this->properties[
"TITLE;".$this->encoding] =
encode($title);
332 $this->properties[
"ORG;".$this->encoding] =
encode($org);
344 $this->properties[
"PRODID"] =
encode($prodid);
356 $this->properties[
"UID"] =
encode($uid);
374 $this->properties[$key] = $url;
384 $text =
"BEGIN:VCARD\r\n";
385 $text .=
"VERSION:4.0\r\n";
387 foreach ($this->properties as $key => $value) {
388 $newkey = preg_replace(
'/-.*$/',
'', $key);
389 $text .= $newkey.
":".$value.
"\r\n";
391 $text .=
"REV:".date(
"Ymd").
"T".date(
"His").
"Z\r\n";
393 $text .=
"END:VCARD\r\n";
405 return $this->filename;
421 global $dolibarr_main_instance_unique_id;
423 $this->
setProdId(
'Dolibarr '.DOL_VERSION);
425 $this->
setUID(
'DOL-USERID-'.
dol_trunc(md5(
'vcard'.$dolibarr_main_instance_unique_id), 8,
'right',
'UTF-8', 1).
'-'.
$object->id);
432 $this->
setPhoto($mimetype, $urlphoto);
450 if (!empty(
$object->socialnetworks)) {
451 foreach (
$object->socialnetworks as $key => $val) {
456 if ($key ==
'linkedin') {
457 if (!preg_match(
'/^http/', $val)) {
458 $urlsn =
'https://www.'.$key.
'.com/company/'.urlencode($val);
462 } elseif ($key ==
'youtube') {
463 if (!preg_match(
'/^http/', $val)) {
464 $urlsn =
'https://www.'.$key.
'.com/user/'.urlencode($val);
469 if (!preg_match(
'/^http/', $val)) {
470 $urlsn =
'https://www.'.$key.
'.com/'.urlencode($val);
476 $this->properties[
"SOCIALPROFILE;TYPE=WORK-".$key] = $key.
':'.$urlsn;
484 $addressalreadyset = 0;
488 $addressalreadyset = 1;
512 if (is_object($company)) {
514 if ($company->typent_code !=
'TE_PRIVATE') {
515 $this->
setOrg($company->name);
518 $this->
setURL($company->url,
"");
520 if ($company->phone && empty(
$object->office_phone)) {
523 if ($company->fax && empty(
$object->office_fax)) {
526 if (($company->address || $company->town || $company->state || $company->zip || $company->country) && !$addressalreadyset) {
527 $this->
setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK");
530 if ($company->email && empty(
$object->email)) {
531 $this->
setEmail($company->email,
"TYPE=WORK");
573 $outfilename = $outdir.
'/virtualcard_'.
$object->element.
'_'.
$object->id.
'.vcf';
575 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.