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=''; $sendtocc='';
$sendtobcc=''; $sendtobcc='';
$sendtoid = array(); $sendtoid = array();
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $sendtouserid=array();
$sendtouserid=array(); $sendtoccuserid=array();
}
// Define $sendto // Define $sendto
$receiver=$_POST['receiver']; $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']; $receiveruser=$_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser)>0) if (is_array($receiveruser) && count($receiveruser)>0)
{ {
$fuserdest = new User($db); $fuserdest = new User($db);
foreach($receiveruser as $key=>$val) foreach($receiveruser as $key=>$val)
{ {
$tmparray[] = $fuserdest->user_get_property($key,'email'); $tmparray[] = $fuserdest->user_get_property($val,'email');
$sendtouserid[] = $key; $sendtouserid[] = $val;
} }
} }
} }
$sendto=implode(',',$tmparray); $sendto=implode(',',$tmparray);
// Define $sendtocc // Define $sendtocc
@ -222,15 +223,15 @@ 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['receiveccruser']; $receiverccuser=$_POST['receiverccuser'];
if (is_array($receiveruser) && count($receiveruser)>0) if (is_array($receiverccuser) && count($receiverccuser)>0)
{ {
$fuserdest = new User($db); $fuserdest = new User($db);
foreach($receiveruser as $key=>$val) foreach($receiverccuser as $key=>$val)
{ {
$tmparray[] = $fuserdest->user_get_property($key,'email'); $tmparray[] = $fuserdest->user_get_property($val,'email');
$sendtouserid[] = $key; $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)) if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{ {
$out.= '<tr><td>'; $out.= '<tr><td>';
$out.= $langs->trans("MailToSalaries"); $out.= $langs->trans("MailToUsers");
$out.= '</td><td>'; $out.= '</td><td>';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time // 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)) if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{ {
$out.= '<tr><td>'; $out.= '<tr><td>';
$out.= $langs->trans("MailToCCSalaries"); $out.= $langs->trans("MailToCCUsers");
$out.= '</td><td>'; $out.= '</td><td>';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time // 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=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); }
elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); }
elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); }
$ret->label = 'default'; $ret->label = 'default';
$ret->lang = $outputlangs->defaultlang; $ret->lang = $outputlangs->defaultlang;
$ret->topic = ''; $ret->topic = '';

View File

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