Fix option MAIN_MAIL_ENABLED_USER_DEST_SELECT

This commit is contained in:
Laurent Destailleur 2018-05-22 20:17:31 +02:00
parent 3c4c48c331
commit f074daae48
3 changed files with 17 additions and 16 deletions

View File

@ -146,9 +146,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$sendtocc='';
$sendtobcc='';
$sendtoid = array();
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$sendtouserid=array();
}
$sendtouserid=array();
$sendtoccuserid=array();
// Define $sendto
$receiver=$_POST['receiver'];
@ -179,18 +178,20 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
}
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
$receiveruser=$_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser)>0)
{
$fuserdest = new User($db);
foreach($receiveruser as $key=>$val)
{
$tmparray[] = $fuserdest->user_get_property($key,'email');
$sendtouserid[] = $key;
$tmparray[] = $fuserdest->user_get_property($val,'email');
$sendtouserid[] = $val;
}
}
}
$sendto=implode(',',$tmparray);
// Define $sendtocc
@ -222,15 +223,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiveruser=$_POST['receiveccruser'];
$receiverccuser=$_POST['receiverccuser'];
if (is_array($receiveruser) && count($receiveruser)>0)
if (is_array($receiverccuser) && count($receiverccuser)>0)
{
$fuserdest = new User($db);
foreach($receiveruser as $key=>$val)
foreach($receiverccuser as $key=>$val)
{
$tmparray[] = $fuserdest->user_get_property($key,'email');
$sendtouserid[] = $key;
$tmparray[] = $fuserdest->user_get_property($val,'email');
$sendtoccuserid[] = $val;
}
}
}

View File

@ -632,7 +632,7 @@ class FormMail extends Form
if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
$out.= '<tr><td>';
$out.= $langs->trans("MailToSalaries");
$out.= $langs->trans("MailToUsers");
$out.= '</td><td>';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
@ -698,7 +698,7 @@ class FormMail extends Form
if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
$out.= '<tr><td>';
$out.= $langs->trans("MailToCCSalaries");
$out.= $langs->trans("MailToCCUsers");
$out.= '</td><td>';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
@ -1112,7 +1112,7 @@ class FormMail extends Form
elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); }
elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); }
elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); }
$ret->label = 'default';
$ret->lang = $outputlangs->defaultlang;
$ret->topic = '';

View File

@ -11,9 +11,9 @@ MailFrom=Sender
MailErrorsTo=Errors to
MailReply=Reply to
MailTo=Receiver(s)
MailToSalaries=To salarie(s)
MailToUsers=To user(s)
MailCC=Copy to
MailToCCSalaries=Copy to salarie(s)
MailToCCUsers=Copy to users(s)
MailCCC=Cached copy to
MailTopic=EMail topic
MailText=Message