* Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2024-2025 Frédéric France * * 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/user/virtualcard.php * \ingroup core * \brief Page to setup a virtual card */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs * @var User $user */ // Load translation files required by page $langs->loadLangs(array("users", "companies", "admin", "website")); // Security check $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); if (empty($id) && empty($ref)) { $id = $user->id; } $expand = empty($_COOKIE['virtualcard_expand']) ? '' : $_COOKIE['virtualcard_expand']; $object = new User($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->loadRights(); } // Security check $socid = 0; if ($user->socid > 0) { $socid = $user->socid; } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not the user that read and has no permission to read other users, we stop if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) { accessforbidden(); } $permissiontoedit = ((($object->id == $user->id) && $user->hasRight('user', 'self', 'creer')) || $user->hasRight('user', 'user', 'creer')); /* * Actions */ if ($action == 'update' && $permissiontoedit) { $tmparray = array(); $tmparray['USER_PUBLIC_MORE'] = GETPOST('USER_PUBLIC_MORE', 'alphanohtml'); dol_set_user_param($db, $conf, $object, array('USER_PUBLIC_MORE' => $tmparray['USER_PUBLIC_MORE'])); } if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) { if (GETPOST('value')) { $tmparray = array('USER_ENABLE_PUBLIC' => 1); } else { $tmparray = array('USER_ENABLE_PUBLIC' => 0); } dol_set_user_param($db, $conf, $object, $tmparray); } /* * View */ $form = new Form($db); $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; $title = $person_name." - ".$langs->trans('Info'); $help_url = ''; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-virtualcard'); $title = $langs->trans("User"); //print dol_get_fiche_head($head, 'info', $title, -1, 'user'); print '
'; print '
'; $param = '&id='.((int) $object->id); if (GETPOSTISSET('dol_openinpopup')) { $param .= '&dol_openinpopup='.urlencode(GETPOST('dol_openinpopup', 'aZ09')); } $enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' '; if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { // Button off, click to enable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; $enabledisablehtml .= '

'.$langs->trans("UserPublicPageDesc").'
'; } else { // Button on, click to disable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } print $enabledisablehtml; print ''; print '
'; if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { print '

'; print ''; print ''; print ''; //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('PublicVirtualCardUrl').'
'; $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external'); $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal'); $showUserSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS', '', $object); $showSocieteSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', '', $object); print ''; print ajax_autoselect('publicurluser'); print '
'; print '
'; // Show/Hide options print '
'; print img_picto('', 'setup', 'class="pictofixedwidth"').''.$langs->trans("ShowAdvancedOptions").'...'; print '
'; print ''; // Start div hide/Show print '
'; print '
'; print ''; print ''; print ''; print ''; print "\n"; // User photo print '\n"; // Job position print '\n"; // Email print '\n"; // Office phone print '\n"; // Office fax print '\n"; // User mobile print '\n"; // Social networks print '\n"; // Show list of socialnetworks for user if ($showUserSocialNetworks) { $socialnetworks = $object->socialnetworks; if (!empty($socialnetworks)) { foreach ($socialnetworks as $key => $networkVal) { print ''; print ''; print ""; } } } // Birth date print '\n"; // Address print '\n"; print ''; print ''; print ''; print "\n"; // Company section print '\n"; if (!getDolUserString('USER_PUBLIC_HIDE_COMPANY', '', $object)) { // Email print '\n"; // URL print '\n"; // Office phone print '\n"; // Office fax print '\n"; // Social networks print '\n"; // Show list of social networks for company if ($showSocieteSocialNetworks) { $listofnetworks = $mysoc->socialnetworks; if (!empty($listofnetworks)) { foreach ($listofnetworks as $key => $networkVal) { print ''; print ''; print ""; } } } } print ''; print ''; print ''; print "\n"; // More print '\n"; print '
'.$langs->trans("User").'
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
    '.$langs->trans("Hide").' '.dol_escape_htmltag($key).''; print ajax_constantonoff('USER_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print '
'; print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("DateOfBirth")); print ''; print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address")); print ''; print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'.$langs->trans("Company").'
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email")); print ''; print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("URL")); print ''; print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_URL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Phone")); print ''; print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax")); print ''; print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
'; print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation")); print ''; print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print "
    '.$langs->trans("Hide").' '.dol_escape_htmltag($key).''; print ajax_constantonoff('SOCIETE_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object); print '
'.$langs->trans("Other").'
'; print $langs->trans("Text"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $extendededitor = 0; // We force no WYSIWYG editor $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%'); $doleditor->Create(); print "
'; print '
'; print '
'; print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup); print '
'; print '
'; print '
'; // End hide/show print '
'; // Preview print '
'; print ''.$langs->trans("Preview").'
'; print ''; print '
'; print '
'; } print '
'; print '
'; // End of page llxFooter(); $db->close();