Skip to content

Commit

Permalink
Merge pull request #8002 from fappels/7.0_fix_on_fix_mail_trigger
Browse files Browse the repository at this point in the history
 Fix on #7981 sendmail trigger error
  • Loading branch information
eldy committed Dec 31, 2017
2 parents affce9c + b6e3d31 commit 24a59a7
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions htdocs/core/actions_sendmails.inc.php
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 24a59a7

Please sign in to comment.