Merge pull request #8002 from fappels/7.0_fix_on_fix_mail_trigger

Fix on #7981 sendmail trigger error
This commit is contained in:
Laurent Destailleur 2017-12-31 12:53:02 +01:00 committed by GitHub
commit 24a59a7731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -392,8 +392,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result) if ($result)
{ {
$error=0;
// FIXME This must be moved into the trigger for action $trigger_name // FIXME This must be moved into the trigger for action $trigger_name
if (! empty($conf->dolimail->enabled)) if (! empty($conf->dolimail->enabled))
{ {
@ -438,17 +436,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
if ($result < 0) { 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 // Redirect here
// This avoid sending mail twice if going out and then back to page // 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)); $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
@ -461,7 +453,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
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:''));
exit; exit;
} }
}
else else
{ {
$langs->load("other"); $langs->load("other");