Skip to content

Commit

Permalink
Fix on Dolibarr#7981
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fappels committed Dec 30, 2017
1 parent 80d9fe3 commit 2e630bf
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions htdocs/core/actions_sendmails.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 2e630bf

Please sign in to comment.