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);
163 public function setName($family =
"", $first =
"", $additional =
"", $prefix =
"", $suffix =
"")
167 $this->filename =
"$first%20$family.vcf";
168 if (empty($this->properties[
"FN"])) {
169 $this->
setFormattedName(trim(
"$prefix $first $additional $family $suffix"));
200 public function setAddress($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"", $label =
"")
208 $key .=
';LABEL="'.encode($label).
'"';
210 $key .=
";".$this->encoding;
232 public function setLabel($postoffice =
"", $extended =
"", $street =
"", $city =
"", $region =
"", $zip =
"", $country =
"", $type =
"HOME")
235 if ($postoffice !=
"") {
236 $label .=
"$postoffice\r\n";
238 if ($extended !=
"") {
239 $label .=
"$extended\r\n";
242 $label .=
"$street\r\n";
248 $label .=
"$city\r\n";
251 $label .=
"$region\r\n";
253 if ($country !=
"") {
254 $country .=
"$country\r\n";
257 $this->properties[
"LABEL;$type;".$this->encoding] =
encode($label);
270 if ($type ==
"PREF") {
272 } elseif (!empty($type)) {
273 $key .=
";TYPE=".dol_strtolower($type);
275 $this->properties[$key] = $address;
286 $this->properties[
"NOTE;".$this->encoding] =
encode($note);
297 $this->properties[
"TITLE;".$this->encoding] =
encode($title);
309 $this->properties[
"ORG;".$this->encoding] =
encode($org);
321 $this->properties[
"PRODID"] =
encode($prodid);
333 $this->properties[
"UID"] =
encode($uid);
351 $this->properties[$key] = $url;
361 $text =
"BEGIN:VCARD\r\n";
362 $text .=
"VERSION:4.0\r\n";
364 foreach ($this->properties as $key => $value) {
365 $newkey = preg_replace(
'/-.*$/',
'', $key);
366 $text .= $newkey.
":".$value.
"\r\n";
368 $text .=
"REV:".date(
"Ymd").
"T".date(
"His").
"Z\r\n";
370 $text .=
"END:VCARD\r\n";
382 return $this->filename;
398 global $dolibarr_main_instance_unique_id;
400 $this->
setProdId(
'Dolibarr '.DOL_VERSION);
402 $this->
setUID(
'DOLIBARR-USERID-'.
dol_trunc(md5(
'vcard'.$dolibarr_main_instance_unique_id), 8,
'right',
'UTF-8', 1).
'-'.
$object->id);
409 $this->
setPhoto($mimetype, $urlphoto);
427 if (!empty(
$object->socialnetworks)) {
428 foreach (
$object->socialnetworks as $key => $val) {
433 if ($key ==
'linkedin') {
434 if (!preg_match(
'/^http/', $val)) {
435 $urlsn =
'https://www.'.$key.
'.com/company/'.urlencode($val);
439 } elseif ($key ==
'youtube') {
440 if (!preg_match(
'/^http/', $val)) {
441 $urlsn =
'https://www.'.$key.
'.com/user/'.urlencode($val);
446 if (!preg_match(
'/^http/', $val)) {
447 $urlsn =
'https://www.'.$key.
'.com/'.urlencode($val);
453 $this->properties[
"SOCIALPROFILE;TYPE=WORK-".$key] = $key.
':'.$urlsn;
488 if (is_object($company)) {
490 if ($company->typent_code !=
'TE_PRIVATE') {
491 $this->
setOrg($company->name);
494 $this->
setURL($company->url,
"");
496 if ($company->phone && $company->phone !=
$object->office_phone) {
499 if ($company->fax && $company->fax !=
$object->office_fax) {
502 if ($company->address || $company->town || $company->state || $company->zip || $company->country) {
503 $this->
setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK");
506 if ($company->email && $company->email !=
$object->email) {
507 $this->
setEmail($company->email,
"TYPE=WORK");
549 $outfilename = $outdir.
'/virtualcard_'.
$object->element.
'_'.
$object->id.
'.vcf';
551 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.