Fix regression losing warning on not defined emails
This commit is contained in:
parent
8fb9a55d8a
commit
be19a999f5
@ -4857,12 +4857,13 @@ class Form
|
|||||||
* @param int $disabled Html select box is disabled
|
* @param int $disabled Html select box is disabled
|
||||||
* @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
|
* @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
|
||||||
* @param string $morecss Add more class to css styles
|
* @param string $morecss Add more class to css styles
|
||||||
* @param int $addjscombo Add js combo
|
* @param int $addjscombo Add js combo
|
||||||
* @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set.
|
* @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set.
|
||||||
* @return string HTML select string.
|
* @param int $disablebademail Check if an email is found into value and if not disable and colorize entry.
|
||||||
|
* @return string HTML select string.
|
||||||
* @see multiselectarray
|
* @see multiselectarray
|
||||||
*/
|
*/
|
||||||
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='')
|
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='',$disablebademail=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@ -4907,7 +4908,10 @@ class Form
|
|||||||
// Translate
|
// Translate
|
||||||
if ($translate)
|
if ($translate)
|
||||||
{
|
{
|
||||||
foreach($array as $key => $value) $array[$key]=$langs->trans($value);
|
foreach($array as $key => $value)
|
||||||
|
{
|
||||||
|
$array[$key]=$langs->trans($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
@ -4916,8 +4920,19 @@ class Form
|
|||||||
|
|
||||||
foreach($array as $key => $value)
|
foreach($array as $key => $value)
|
||||||
{
|
{
|
||||||
|
$disabled=''; $style='';
|
||||||
|
if (! empty($disablebademail))
|
||||||
|
{
|
||||||
|
if (! preg_match('/<.+@.+>/', $value))
|
||||||
|
{
|
||||||
|
//$value=preg_replace('/'.preg_quote($a,'/').'/', $b, $value);
|
||||||
|
$disabled=' disabled';
|
||||||
|
$style=' class="warning"';
|
||||||
|
}
|
||||||
|
}
|
||||||
$out.='<option value="'.$key.'"';
|
$out.='<option value="'.$key.'"';
|
||||||
if ($id != '' && $id == $key) $out.=' selected'; // To preselect a value
|
$out.=$style.$disabled;
|
||||||
|
if ($id != '' && $id == $key && ! $disabled) $out.=' selected'; // To preselect a value
|
||||||
$out.='>';
|
$out.='>';
|
||||||
|
|
||||||
if ($key_in_label)
|
if ($key_in_label)
|
||||||
@ -4929,6 +4944,7 @@ class Form
|
|||||||
$selectOptionValue = dol_escape_htmltag($maxlen?dol_trunc($value,$maxlen):$value);
|
$selectOptionValue = dol_escape_htmltag($maxlen?dol_trunc($value,$maxlen):$value);
|
||||||
if ($value == '' || $value == '-') $selectOptionValue=' ';
|
if ($value == '' || $value == '-') $selectOptionValue=' ';
|
||||||
}
|
}
|
||||||
|
//var_dump($selectOptionValue);
|
||||||
$out.=$selectOptionValue;
|
$out.=$selectOptionValue;
|
||||||
$out.="</option>\n";
|
$out.="</option>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -264,6 +264,8 @@ class FormMail extends Form
|
|||||||
{
|
{
|
||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
|
$disablebademails=1;
|
||||||
|
|
||||||
// Define list of attached files
|
// Define list of attached files
|
||||||
$listofpaths=array();
|
$listofpaths=array();
|
||||||
$listofnames=array();
|
$listofnames=array();
|
||||||
@ -392,7 +394,15 @@ class FormMail extends Form
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$liste = array();
|
$liste = array();
|
||||||
$liste['user'] = $user->getFullName($langs) .' <'.$user->email.'>';
|
if (empty($user->email))
|
||||||
|
{
|
||||||
|
$langs->load('errors');
|
||||||
|
$liste['user'] = $user->getFullName($langs) . ' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$liste['user'] = $user->getFullName($langs) .' <'.$user->email.'>';
|
||||||
|
}
|
||||||
$liste['company'] = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
|
$liste['company'] = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
|
||||||
// Add also email aliases if there is one
|
// Add also email aliases if there is one
|
||||||
$listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
|
$listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
|
||||||
@ -413,7 +423,7 @@ class FormMail extends Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0);
|
$out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.= "</td></tr>\n";
|
$out.= "</td></tr>\n";
|
||||||
@ -510,7 +520,7 @@ class FormMail extends Form
|
|||||||
if (! empty($this->withto) && is_array($this->withto))
|
if (! empty($this->withto) && is_array($this->withto))
|
||||||
{
|
{
|
||||||
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
|
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
|
||||||
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
|
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
||||||
}
|
}
|
||||||
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
|
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
|
||||||
{
|
{
|
||||||
@ -522,7 +532,7 @@ class FormMail extends Form
|
|||||||
$liste[$key]=$value;
|
$liste[$key]=$value;
|
||||||
}
|
}
|
||||||
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
|
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
|
||||||
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
|
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.= "</td></tr>\n";
|
$out.= "</td></tr>\n";
|
||||||
@ -544,7 +554,7 @@ class FormMail extends Form
|
|||||||
if (! empty($this->withtocc) && is_array($this->withtocc))
|
if (! empty($this->withtocc) && is_array($this->withtocc))
|
||||||
{
|
{
|
||||||
$out.= " ".$langs->trans("or")." ";
|
$out.= " ".$langs->trans("or")." ";
|
||||||
$out.= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1);
|
$out.= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.= "</td></tr>\n";
|
$out.= "</td></tr>\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user