From d169162ef12d370fa8994414cbdcc6aaa635d331 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 May 2020 22:56:29 +0200 Subject: [PATCH] Revert "NEW enable free emails input with select2" --- htdocs/core/actions_sendmails.inc.php | 8 +--- htdocs/core/class/html.form.class.php | 46 ++--------------------- htdocs/core/class/html.formmail.class.php | 16 ++++++-- htdocs/core/lib/project.lib.php | 2 +- htdocs/langs/en_US/mails.lang | 1 - 5 files changed, 19 insertions(+), 54 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index d6c4c0a6313..e23d2ce01a9 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -190,12 +190,10 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; } - elseif ((int) $val > 0) // $val is the Id of a contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; - } else { - $tmparray[] = $val; } } } @@ -242,12 +240,10 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; } - elseif ((int) $val > 0) // $val is the Id of a contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? - } else { - $tmparray[] = $val; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6d1ce33b0be..622ffb1d127 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6621,11 +6621,10 @@ class Form * @param string $elemtype Type of element we show ('category', ...). Will execute a formating function on it. To use in readonly mode if js component support HTML formatting. * @param string $placeholder String to use as placeholder * @param int $addjscombo Add js combo - * @param int $enablefreetag 0 no free tag, 1 enable free tag for elemtype * @return string HTML multiselect string * @see selectarray(), selectArrayAjax(), selectArrayFilter() */ - public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1, $enablefreetag = 0) + public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1) { global $conf, $langs; @@ -6667,50 +6666,13 @@ class Form $out .= '$(document).ready(function () { $(\'#'.$htmlname.'\').'.$tmpplugin.'({ dir: \'ltr\', - tags: '.($enablefreetag?'true':'false').', // Specify format function for dropdown item formatResult: formatResult, - /* For 4.0 */ - templateResult: formatResult, + templateResult: formatResult, /* For 4.0 */ // Specify format function for selected item formatSelection: formatSelection, - /* For 4.0 */ - templateSelection: formatSelection'; - if ($enablefreetag && $elemtype == 'email') { - $out .= ', - createTag: function (params) { - var REGEX_EMAIL = "([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@" + - "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)"; - // Dont offset to create a tag if there is no @ symbol - if (params.term.indexOf("@") === -1) { - // Return null to disable tag creation - return null; - } - var match = params.term.match(new RegExp("^([^<]*)\<" + REGEX_EMAIL + "\>$", "i")); - // console.log(match); - if (match !== null) { - return { - id: $.trim(match[1]) + " <" + match[2] + ">", - text: $.trim(match[1]) + " <" + match[2] + ">" - } - } - if (params.term.indexOf("<") >= 0) { - // Return null to disable tag creation - return null; - } - var match = params.term.match(new RegExp("^" + REGEX_EMAIL + "$", "i")); - // console.log(match); - if (match !== null) { - var pos = params.term.indexOf("@"); - return { - id: $.trim(match[1].substring(0, pos)) + " <" + match[1] + ">", - text: $.trim(match[1].substring(0, pos)) + " <" + match[1] + ">" - } - } - return null; - }'; - } - $out .= ' }); + templateSelection: formatSelection /* For 4.0 */ + }); });'."\n"; } elseif ($addjscombo == 2) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8881b93349f..d961cd20536 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -630,7 +630,7 @@ class FormMail extends Form if (!empty($this->withto) || is_array($this->withto)) { $out .= ''; - if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseFreeEmailsForRecipients")); + if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); else $out .= $langs->trans("MailTo"); $out .= ''; if ($this->withtoreadonly) @@ -669,9 +669,15 @@ class FormMail extends Form } else { + // The free input of email + if (!empty($this->withtofree)) + { + $out .= 'withto) : "")).'" />'; + } // The select combo if (!empty($this->withto) && is_array($this->withto)) { + if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withto; foreach ($tmparray as $key => $val) @@ -683,7 +689,7 @@ class FormMail extends Form { $withtoselected = array_keys($tmparray); } - $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', 0, '', '', 'email', '', -1, !empty($this->withtofree)?1:0); + $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); } } $out .= "\n"; @@ -730,7 +736,7 @@ class FormMail extends Form if (!empty($this->withtocc) || is_array($this->withtocc)) { $out .= ''; - $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseFreeEmailsForRecipients")); + $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= ''; if ($this->withtoccreadonly) { @@ -738,8 +744,10 @@ class FormMail extends Form } else { + $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { + $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtocc; foreach ($tmparray as $key => $val) @@ -747,7 +755,7 @@ class FormMail extends Form $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } $withtoccselected = GETPOST("receivercc"); // Array of selected value - $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', 0, '', '', 'email', '', -1, !empty($this->withtofree)?1:0); + $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); } } $out .= "\n"; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index aa568bedce3..bef3d9fd0dc 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2288,7 +2288,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $total_plannedworkload += $plannedworkload; if (!in_array('plannedworkload', $hiddenfields)) { - print ''.($plannedworkload ? convertSecondToTime($plannedworkload) : '').''; + print ''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').''; } if (!in_array('declaredprogress', $hiddenfields)) { diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 9806748a1c0..7b3bfd3852a 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -117,7 +117,6 @@ NbOfEMailingsSend=Mass emailings sent IdRecord=ID record DeliveryReceipt=Delivery Ack. YouCanUseCommaSeparatorForSeveralRecipients=You can use the comma separator to specify several recipients. -YouCanUseFreeEmailsForRecipients=You can enter free emails to specify several recipients. TagCheckMail=Track mail opening TagUnsubscribe=Unsubscribe link TagSignature=Signature of sending user