* Copyright (C) 2005-2015 Regis Houssin * * 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/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // 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; } $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_HIDE_PHOTO'] = (GETPOST('USER_PUBLIC_HIDE_PHOTO') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_JOBPOSITION'] = (GETPOST('USER_PUBLIC_HIDE_JOBPOSITION') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_EMAIL'] = (GETPOST('USER_PUBLIC_HIDE_EMAIL') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_OFFICE_PHONE'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_PHONE') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_OFFICE_FAX'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_FAX') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_USER_MOBILE'] = (GETPOST('USER_PUBLIC_HIDE_USER_MOBILE') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS') ? 1 : 0); $tmparray['USER_PUBLIC_SHOW_BIRTH'] = (GETPOST('USER_PUBLIC_SHOW_BIRTH') ? 1 : 0); $tmparray['USER_PUBLIC_SHOW_ADDRESS'] = (GETPOST('USER_PUBLIC_SHOW_ADDRESS') ? 1 : 0); $tmparray['USER_PUBLIC_HIDE_COMPANY'] = (GETPOST('USER_PUBLIC_HIDE_COMPANY') ? 1 : 0); $tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : ''); dol_set_user_param($db, $conf, $object, $tmparray); } 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'); $head = user_prepare_head($object); $title = $langs->trans("User"); //print dol_get_fiche_head($head, 'info', $title, -1, 'user'); $linkback = ''; if ($user->hasRight('user', 'user', 'lire') || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); print '
'; print '
'; $param = '&id='.((int) $object->id); $param .= '&dol_openinpopup=1'; $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 '

'; print '
'; if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { print ''; print ''; print ''; //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('PublicVirtualCardUrl').'
'; $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external'); $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal'); 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 ''; // End hide/show print '
'; // Preview print '
'; print ''.$langs->trans("Preview").'
'; print ''; print '
'; print '
'; } print '
'; print '
'; // End of page llxFooter(); $db->close();