diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1d3d4b2adea..300c06216f7 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -377,9 +377,11 @@ if (! $error && $massaction == 'confirm_presend') $subjectreplaced=make_substitutions($subject, $substitutionarray); $messagereplaced=make_substitutions($message, $substitutionarray); + $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if($oneemailperrecipient) { + // if "one email per recipient" isn't check we must collate $attachedfiles by thirdparty if(is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){ @@ -394,6 +396,7 @@ if (! $error && $massaction == 'confirm_presend') } elseif(!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){ // Create form object + // if "one email per recipient" isn't check we must separate $attachedfiles by object $attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; } diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 0a273072e29..e525bd739a3 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -107,7 +107,8 @@ if ($massaction == 'presend') $formmail->withtoreadonly = 1; } - $formmail->withoptiononeemailperrecipient = (count($listofselectedref) == 1 || empty($liste))? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1); + $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1); + $formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste; $formmail->withtofree = empty($liste)?1:0; $formmail->withtocc = 1; @@ -126,6 +127,7 @@ if ($massaction == 'presend') // Make substitution in email content $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); + $substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated