From 1e2cd27218340b7df86b7184bddc9ea431483daa Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 19 Feb 2024 17:21:13 +0100 Subject: [PATCH 1/5] Fixed email sticking to url. Refactored dol_print_url HTML structure to standardize with dol_print_email. --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e49c44ebb2b8e..ce8a2a90ced91 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3372,7 +3372,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor if ($morecss == 'float') { // deprecated return '
'.($withpicto ? img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } else { - return $linkstart.''.($withpicto ? img_picto('', 'globe').' ' : '').$link.''.$linkend; + return ''.($withpicto ? img_picto('', 'globe').' ' : '').$linkstart.$link.$linkend.''; } } @@ -3433,9 +3433,9 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, } } - //$rep = '
'; - $rep = ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '').$newemail; - //$rep .= '
'; + $rep = ''; + $rep .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '').$newemail; + $rep .= ''; if ($hookmanager) { $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); From 07e75087ffb9de7f42f5da5171873163e9f9c61d Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 19 Feb 2024 17:22:33 +0100 Subject: [PATCH 2/5] Added contributor details --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ce8a2a90ced91..8d4c7030003f7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -23,6 +23,7 @@ * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 MDW * Copyright (C) 2024 Lenin Rivas + * Copyright (C) 2024 William Mead * * 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 From fcbd9bbca02fa902143f67ee7f2e466f16b39008 Mon Sep 17 00:00:00 2001 From: William Mead Date: Tue, 20 Feb 2024 13:25:32 +0100 Subject: [PATCH 3/5] Revert dol_print_url HTML structure --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8d4c7030003f7..e605bf1044aec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3373,7 +3373,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor if ($morecss == 'float') { // deprecated return '
'.($withpicto ? img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } else { - return ''.($withpicto ? img_picto('', 'globe').' ' : '').$linkstart.$link.$linkend.''; + return $linkstart.''.($withpicto ? img_picto('', 'globe').' ' : '').$link.''.$linkend; } } From 2d413550b30cb0419b4f9a74a0c1125b013fca3a Mon Sep 17 00:00:00 2001 From: William Mead Date: Tue, 20 Feb 2024 14:38:26 +0100 Subject: [PATCH 4/5] Refactored email link to include picto --- htdocs/core/lib/functions.lib.php | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e605bf1044aec..07f400cf68450 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3391,9 +3391,9 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor */ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0) { - global $conf, $user, $langs, $hookmanager; + global $user, $langs, $hookmanager; - $newemail = dol_escape_htmltag($email); + $emailLink = ''; if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') && $withpicto) { $withpicto = 0; @@ -3404,17 +3404,17 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, } if (!empty($addlink)) { - $newemail = ''; - $newemail .= dol_trunc($email, $max); - $newemail .= ''; + $emailLink .= $email; + $emailLink .= '">'; + $emailLink .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '') . dol_trunc($email, $max); + $emailLink .= ''; if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); + $emailLink .= img_warning($langs->trans("ErrorBadEMail", $email)); } if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) { @@ -3424,30 +3424,30 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $link = ''.img_object($langs->trans("AddAction"), "calendar").''; } if ($link) { - $newemail = '
'.$newemail.' '.$link.'
'; + $emailLink = '
'.$emailLink.' '.$link.'
'; } } } else { if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); + $emailLink .= img_warning($langs->trans("ErrorBadEMail", $email)); } + $emailLink .= ''; + $emailLink .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '') . dol_trunc($email, $max); + $emailLink .= ''; } - $rep = ''; - $rep .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '').$newemail; - $rep .= ''; if ($hookmanager) { $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email); if ($reshook > 0) { - $rep = ''; + $emailLink = ''; } - $rep .= $hookmanager->resPrint; + $emailLink .= $hookmanager->resPrint; } - return $rep; + return $emailLink; } /** From 9f233483f64b4254e5fa6abc6d3892d8e57c4126 Mon Sep 17 00:00:00 2001 From: William Mead Date: Tue, 20 Feb 2024 14:46:46 +0100 Subject: [PATCH 5/5] Added thirdparty email link --- htdocs/contrat/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index f21e19b43a190..d6d688ef27a48 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -1183,7 +1183,7 @@ } // Email if (!empty($arrayfields['s.email']['checked'])) { - print ''.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; + print ''.dol_print_email($obj->email, 0, $obj->socid, 1, 0, 1, 1).''; } // Town if (!empty($arrayfields['s.town']['checked'])) {