From b6e3d312adadfaeed05e17676369bb45acef155d Mon Sep 17 00:00:00 2001 From: fappels Date: Sat, 30 Dec 2017 12:12:13 +0100 Subject: [PATCH] Fix on #7981 Trigger interface does not set error eventmessage. Improvement: Show both trigger error and mail send succesful, so you know mail was send succesful bot some trigger action after sending mail failed. --- htdocs/core/actions_sendmails.inc.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 1544bd36fce4e..ba930158d90f1 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -392,8 +392,6 @@ $result=$mailfile->sendfile(); if ($result) { - $error=0; - // FIXME This must be moved into the trigger for action $trigger_name if (! empty($conf->dolimail->enabled)) { @@ -438,29 +436,22 @@ $interface=new Interfaces($db); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); if ($result < 0) { - $error++; $errors=$interface->errors; + setEventMessages($interface->error, $interface->errors, 'errors'); } } } - if ($error) - { - // error message event set by trigger interface - } - else + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessages($mesg, null, 'mesgs'); + if ($conf->dolimail->enabled) { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) - { - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - exit; - } - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); exit; } + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); + exit; } else {