Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix email & url presentation #28279

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htdocs/contrat/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@
}
// Email
if (!empty($arrayfields['s.email']['checked'])) {
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).'">'.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).'</td>';
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).'">'.dol_print_email($obj->email, 0, $obj->socid, 1, 0, 1, 1).'</td>';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) {
Expand Down
35 changes: 18 additions & 17 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Lenin Rivas <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* 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
Expand Down Expand Up @@ -3390,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;
Expand All @@ -3403,17 +3404,17 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
}

if (!empty($addlink)) {
$newemail = '<a style="text-overflow: ellipsis;" href="';
$emailLink = '<a style="text-overflow: ellipsis;" href="';
if (!preg_match('/^mailto:/i', $email)) {
$newemail .= 'mailto:';
$emailLink .= 'mailto:';
}
$newemail .= $email;
$newemail .= '">';
$newemail .= dol_trunc($email, $max);
$newemail .= '</a>';
$emailLink .= $email;
$emailLink .= '"><span class="nospan" style="margin-right: 10px">';
$emailLink .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '') . dol_trunc($email, $max);
$emailLink .= '</span></a>';
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")) {
Expand All @@ -3423,30 +3424,30 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
$link = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$type.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
}
if ($link) {
$newemail = '<div>'.$newemail.' '.$link.'</div>';
$emailLink = '<div>'.$emailLink.' '.$link.'</div>';
}
}
} else {
if ($showinvalid && !isValidEmail($email)) {
$langs->load("errors");
$newemail .= img_warning($langs->trans("ErrorBadEMail", $email));
$emailLink .= img_warning($langs->trans("ErrorBadEMail", $email));
}
$emailLink .= '<span class="nospan" style="margin-right: 10px">';
$emailLink .= ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '') . dol_trunc($email, $max);
$emailLink .= '</span>';
}

//$rep = '<div class="nospan" style="margin-right: 10px">';
$rep = ($withpicto ? img_picto($langs->trans("EMail").' : '.$email, (is_numeric($withpicto) ? 'email' : $withpicto)).' ' : '').$newemail;
//$rep .= '</div>';
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;
}

/**
Expand Down
Loading