*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/**
* \file htdocs/public/users/view.php
* \ingroup user
* \brief Public file to user profile
*/
if (!defined('NOLOGIN')) {
define("NOLOGIN", 1); // This means this output page does not require to be logged.
}
if (!defined('NOCSRFCHECK')) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', '1');
}
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies", "other", "recruitment"));
// Get parameters
$action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = '';
$id = GETPOST('id', 'int');
$securekey = GETPOST('securekey', 'alpha');
$suffix = GETPOST('suffix');
$object = new User($db);
$object->fetch($id, '', '', 1);
// Define $urlwithroot
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
// Security check
global $dolibarr_main_instance_unique_id;
$encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$object->id.'-'.$object->login, 'md5');
if ($encodedsecurekey != $securekey) {
httponly_accessforbidden('Bad value for securitykey or public profile not enabled');
}
if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
httponly_accessforbidden('Bad value for securitykey or public profile not enabled');
}
/*
* Actions
*/
if ($cancel) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
$action = 'view';
}
/*
* View
*/
$form = new Form($db);
$v = new vCard();
$company = $mysoc;
$modulepart = 'userphotopublic';
$dir = $conf->user->dir_output;
// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
// Define logo and logosmall
$logo = '';
$logosmall = '';
if (!empty($object->photo)) {
if (dolIsAllowedForPreview($object->photo)) {
$logosmall = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_small');
$logo = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo;
//$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo;
}
}
//print ''."\n";
// Define urllogo
$urllogo = '';
$urllogofull = '';
if (!empty($logosmall) && is_readable($dir.'/'.$logosmall)) {
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall);
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall);
} elseif (!empty($logo) && is_readable($dir.'/'.$logo)) {
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logo);
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&securekey='.urlencode($securekey).'&file='.urlencode($logo);
}
// Clean data we don't want on public page
if (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object)) {
$logo = '';
$logosmall = '';
$urllogo = '';
$urllogofull = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) {
$object->job = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) {
$object->email = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) {
$object->job = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) {
$object->office_phone = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) {
$object->office_fax = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) {
$object->user_mobile = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object)) {
$object->birth = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) {
$object->socialnetworks = '';
}
if (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) {
$company = null;
}
// Output vcard
if ($mode == 'vcard') {
// Reset data no selected for public VCard
// We create VCard
$output = $v->buildVCardString($object, $company, $langs, $urllogofull);
$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
//$filename = dol_sanitizeFileName($filename);
top_httphead('text/x-vcard; name="'.$filename.'"');
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Length: ".dol_strlen($output));
header("Connection: close");
print $output;
$db->close();
exit;
}
$head = '';
if (!empty($conf->global->MAIN_USER_PROFILE_CSS_URL)) {
$head = ''."\n";
}
$conf->dol_hide_topmenu = 1;
$conf->dol_hide_leftmenu = 1;
if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
$langs->load("errors");
print '