From 7ebb5f7d92aca7a72996e242c53eb6bd17ecd7ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jan 2017 13:06:26 +0100 Subject: [PATCH] FIX #6270 --- htdocs/core/actions_sendmails.inc.php | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9ec3bfcb3b7..28799231fdd 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -337,24 +337,27 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } // Initialisation of datas - $object->socid = $sendtosocid; // To link to a company - $object->sendtoid = $sendtoid; // To link to a contact/address - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text - $object->trackid = $trackid; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Call of triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $errors=$interface->errors; + if (is_object($object)) + { + $object->socid = $sendtosocid; // To link to a company + $object->sendtoid = $sendtoid; // To link to a contact/address + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text + $object->trackid = $trackid; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Call of triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $errors=$interface->errors; + } + // End call of triggers } - // End call of triggers - + if ($error) { dol_print_error($db);