dolibarr 21.0.0-beta
vcard.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
6 * Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
32require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php';
42$id = GETPOSTINT('id');
43
44// Security check
45$socid = 0;
46if ($user->socid > 0) {
47 $socid = $user->socid;
48}
49$feature2 = 'user';
50$result = restrictedArea($user, 'user', $id, 'user', $feature2);
51
52$object = new User($db);
53$result = $object->fetch($id);
54if ($result <= 0) {
55 dol_print_error($db, $object->error);
56 exit;
57}
58
59// Data from linked company
60$company = new Societe($db);
61if ($object->socid > 0) {
62 $result = $company->fetch($object->socid);
63}
64
65
66/*
67 * View
68 */
69
70if (GETPOST('mode') == 'virtualcard') {
71 // Clean the data to show according to options
72 if (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object)) {
73 $object->photo = '';
74 }
75 if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) {
76 $object->email = '';
77 }
78 if (getDolUserInt('USER_PUBLIC_HIDE_URL', 0, $object)) {
79 $object->url = '';
80 }
81 if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) {
82 $object->office_phone = '';
83 }
84 if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) {
85 $object->office_fax = '';
86 }
87 if (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) {
88 $object->user_mobile = '';
89 }
90 if (!getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object)) {
91 $object->birth = '';
92 }
93 if (!getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object)) {
94 $object->country_code = '';
95 $object->zip = '';
96 $object->address = '';
97 }
98 if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) {
99 $object->socialnetworks = array();
100 }
101
102 // Business section
103 if (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) || getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object)) {
104 $company->socialnetworks = array();
105 }
106}
107
108// We create VCard
109$v = new vCard();
110$output = $v->buildVCardString($object, $company, $langs);
111
112$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
113$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
114//$filename = dol_sanitizeFileName($filename);
115
116top_httphead('text/x-vcard; name="'.$filename.'"');
117
118header("Content-Disposition: attachment; filename=\"".$filename."\"");
119header("Content-Length: ".dol_strlen($output));
120header("Connection: close");
121
122print $output;
123
124$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Class to build vCard files.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.