From 25842b3295e49a474950bf6fa4c22f17208924da Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 2 Jul 2015 16:03:24 +0200 Subject: [PATCH 1/2] NEW add hook in send mail --- htdocs/core/class/CMailFile.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index ef6d27b59b1..65bdd28e3ee 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -366,13 +366,26 @@ class CMailFile */ function sendfile() { - global $conf; + global $conf,$db; $errorlevel=error_reporting(); error_reporting($errorlevel ^ E_WARNING); // Desactive warnings $res=false; + dol_include_once('/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($db); + $hookmanager->initHooks(array('maildao')); + $reshook=$hookmanager->executeHooks('doactions',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (!empty($reshook)) + { + + $this->error="Error in hook maildao doactions ".$reshook; + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + + return $reshook; + } + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { // Action according to choosed sending method From 1277596242a9317c29bf2b0967db32a247c96516 Mon Sep 17 00:00:00 2001 From: Alexis ALGOUD Date: Mon, 6 Jul 2015 00:51:17 +0200 Subject: [PATCH 2/2] Mode hook in $conf->global->MAIN_DISABLE_ALL_MAILS --- htdocs/core/class/CMailFile.class.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 65bdd28e3ee..2c58848fe4f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -373,21 +373,22 @@ class CMailFile $res=false; - dol_include_once('/core/class/hookmanager.class.php'); - $hookmanager=new HookManager($db); - $hookmanager->initHooks(array('maildao')); - $reshook=$hookmanager->executeHooks('doactions',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (!empty($reshook)) - { - - $this->error="Error in hook maildao doactions ".$reshook; - dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - - return $reshook; - } - if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + + dol_include_once('/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($db); + $hookmanager->initHooks(array('maildao')); + $reshook=$hookmanager->executeHooks('doactions',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (!empty($reshook)) + { + + $this->error="Error in hook maildao doactions ".$reshook; + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + + return $reshook; + } + // Action according to choosed sending method if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') {