diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a3df6705df9..2aceb437d23 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -634,19 +634,27 @@ if (empty($reshook)) $msg = $arraydefaultmessage->content; } - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); + if (empty($labeltouse) || (int)$labeltouse === -1) { + //fallback on the old configuration. + setEventMessages('WarningMandatorySetupNotComplete', [], 'errors'); + $error++; + }else{ + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); + + $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } - $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - if ($result < 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } } } else @@ -707,20 +715,28 @@ if (empty($reshook)) $msg = $arraydefaultmessage->content; } - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); + if (empty($labeltouse) || (int)$labeltouse === -1) { + //fallback on the old configuration. + setEventMessages('WarningMandatorySetupNotComplete', [], 'errors'); + $error++; + }else{ + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); + + $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } - if ($result < 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a7296ddd5df..87e63517ac2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6530,7 +6530,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb /** * Get formated error messages to output (Used to show messages on html output). * - * @param string $mesgstring Error message + * @param string $mesgstring Error message * @param array $mesgarray Error messages array * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) * @return string Return html output @@ -6538,7 +6538,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb * @see dol_print_error * @see dol_htmloutput_mesg */ -function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) +function get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0) { return get_htmloutput_mesg($mesgstring, $mesgarray,'error',$keepembedded); } @@ -6548,15 +6548,15 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) * * @param string $mesgstring Message string or message key * @param string[] $mesgarray Array of message strings or message keys - * @param string $style Which style to use ('ok', 'warning', 'error') - * @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify) - * @return void + * @param string $style Which style to use ('ok', 'warning', 'error') + * @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify) + * @return void * - * @see dol_print_error - * @see dol_htmloutput_errors - * @see setEventMessages + * @see dol_print_error + * @see dol_htmloutput_errors + * @see setEventMessages */ -function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0) +function dol_htmloutput_mesg($mesgstring = '',$mesgarray = array(), $style = 'ok', $keepembedded=0) { if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return; @@ -6610,7 +6610,7 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb * @see dol_print_error * @see dol_htmloutput_mesg */ -function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) +function dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0) { dol_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded); }