Debug v21

This commit is contained in:
Laurent Destailleur 2024-11-24 13:00:08 +01:00
parent ef88eeeffd
commit fb3c464555
4 changed files with 56 additions and 29 deletions

View File

@ -639,14 +639,14 @@ function ajax_event($htmlname, $events)
* @param string $suffix Suffix to use on the name of the switch picto when option is on. Example: '', '_red'
* @param string $mode Add parameter &mode= to the href link (Used for href link)
* @param string $morecss More CSS
* @param int $userconst 1=OnOff for user constant of user $userconst
* @param User|int $userconst If set, use the ajax On/Off for user or user ID $userconst
* @param string $showwarning String to show a warning when enabled the option
* @return string
* @see ajax_object_onoff() to update the status of an object
*/
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix = '', $mode = '', $morecss = 'inline-block', $userconst = 0, $showwarning = '')
{
global $conf, $langs, $user;
global $conf, $langs, $user, $db;
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
if (!isset($input)) {
@ -660,6 +660,14 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
$out = '<a '.($morecss ? 'class="'.$morecss.'" ' : '').' href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&token='.newToken().'&entity='.$entity.($mode ? '&mode='.$mode : '').($forcereload ? '&dol_resetcache=1' : '').'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
}
} else {
if (is_object($userconst)) {
$userconstid = $userconst->id;
} elseif (is_numeric($userconstid) && $userconstid > 0) {
$userconstid = $userconst;
$userconst = new User($db);
$userconst->fetch($userconstid);
}
$out = "\n<!-- Ajax code to switch constant ".$code." -->".'
<script>
$(document).ready(function() {
@ -669,7 +677,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
var entity = \''.dol_escape_js($entity).'\';
var strict = \''.dol_escape_js((string) $strict).'\';
var userid = \''.dol_escape_js((string) $user->id).'\';
var userconst = '.((int) $userconst).';
var userconst = '.((int) $userconstid).';
var yesButton = \''.dol_escape_js($langs->transnoentities("Yes")).'\';
var noButton = \''.dol_escape_js($langs->transnoentities("No")).'\';
var token = \''.currentToken().'\';
@ -708,8 +716,8 @@ console.log("ee");
});
</script>'."\n";
if ($userconst) {
$value = getDolUserString($code);
if (!empty($userconst) && $userconst instanceof User) {
$value = getDolUserString($code, '', $userconst);
} else {
$value = getDolGlobalString($code);
}

View File

@ -4039,7 +4039,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
$link = str_replace('{socialid}', $value, getDolGlobalString($networkconstname));
if (preg_match('/^https?:\/\//i', $link)) {
$htmllink .= '<a href="'.dol_sanitizeUrl($link, 0).'" target="_blank" rel="noopener noreferrer">'.dol_escape_htmltag($value).'</a>';
} else {
} elseif ($link) {
$htmllink .= '<a href="'.dol_sanitizeUrl($link, 1).'" target="_blank" rel="noopener noreferrer">'.dol_escape_htmltag($value).'</a>';
}
} elseif (!empty($dictsocialnetworks[$type]['url'])) {

View File

@ -99,7 +99,6 @@ if ($cancel) {
* View
*/
$form = new Form($db);
$v = new vCard();
$company = $mysoc;
@ -157,9 +156,20 @@ if (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) {
}
if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) {
$object->socialnetworks = [];
} else {
// Show list of social networks for company
$listofnetworks = $object->socialnetworks;
if (!empty($listofnetworks)) {
foreach ($listofnetworks as $key => $networkVal) {
if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), 0, $object)) {
unset($object->socialnetworks[$key]);
}
}
}
}
// By default, personal address not visible
// By default, personal birthdate and address is not visible
if (!getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object)) {
$object->birth = null;
}
@ -176,8 +186,18 @@ if (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) {
}
if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object) && is_object($company)) {
$company->socialnetworks = [];
}
} else {
// Show list of social networks for company
$listofnetworks = $mysoc->socialnetworks;
if (!empty($listofnetworks)) {
foreach ($listofnetworks as $key => $networkVal) {
if (getDolUserInt('SOCIETE_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), 0, $object)) {
unset($mysoc->socialnetworks[$key]);
}
}
}
}
// Output vcard
if ($mode == 'vcard') {
@ -220,7 +240,7 @@ $arrayofjs = array();
$arrayofcss = array();
$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'.(GETPOST('mode')=='preview' ? ' scalepreview cursorpointer virtualcardpreview' : ''), $replacemainarea, 1, 1);
llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'onlinepaymentbody'.(GETPOST('mode') == 'preview' ? ' scalepreview cursorpointer virtualcardpreview' : ''), $replacemainarea, 1, 1);
print '
<style>
@ -351,10 +371,10 @@ if (getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) && $object->address) {
// Social networks
if (!empty($object->socialnetworks) && is_array($object->socialnetworks)) {
if (!getDolGlobalInt('USER_PUBLIC_HIDE_SOCIALNETWORKS')) {
if (!getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) {
$listOfSocialNetworks = $object->socialnetworks;
foreach ($listOfSocialNetworks as $key => $value) {
if (getDolGlobalString('USER_SOCIALNETWORK_'.strtoupper($key))) {
if (!getDolUserString('USER_HIDE_SOCIALNETWORK_'.strtoupper($key), 0, $object)) {
$usersection .= '<div class="flexitemsmall">'.dol_print_socialnetworks($key, 0, $object->id, strtolower($key), $socialnetworksdict).'</div>';
}
}
@ -424,9 +444,9 @@ if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) {
// Social networks
if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
if (!getDolGlobalInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0)) {
if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object)) {
foreach ($mysoc->socialnetworks as $key => $value) {
if (getDolGlobalString('SOCIETE_PUBLIC_SOCIALNETWORKS_'.strtoupper($key))) {
if (!getDolUserInt('SOCIETE_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), 0, $object)) {
$companysection .= '<div class="flexitemsmall wordbreak">'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'</div>';
}
}

View File

@ -217,60 +217,59 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Job position
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Email
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Office phone
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Office fax
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// User mobile
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Social networks
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Show list of socialnetworks for user
if ($showUserSocialNetworks) {
$socialnetworks = $object->socialnetworks;
if (!empty($socialnetworks)) {
foreach ($socialnetworks as $key => $networkVal) {
print '<tr class="oddeven">';
print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
print ajax_constantonoff('USER_SOCIALNETWORK_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff('USER_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print '</td>';
print "</tr>";
}
@ -281,14 +280,14 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Birthdate"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// Address
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
print '<tr class="liste_titre">';
@ -300,7 +299,7 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tramount"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
if (!getDolUserString('USER_PUBLIC_HIDE_COMPANY', '', $object)) {
@ -308,10 +307,10 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
print '</td><td>';
print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print "</td></tr>\n";
// show list of social networks for company
// Show list of social networks for company
if ($showSocieteSocialNetworks) {
$listofnetworks = $mysoc->socialnetworks;
@ -319,7 +318,7 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
foreach ($listofnetworks as $key => $networkVal) {
print '<tr class="oddeven">';
print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
print ajax_constantonoff('SOCIETE_PUBLIC_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
print ajax_constantonoff('SOCIETE_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
print '</td>';
print "</tr>";
}