Hook 'maildao' was renamed into 'mail' into the method sendfile that

send emails, and method was renamed from 'doaction' into 'sendMail'.
To process task #4875 #7969 in several steps.
This commit is contained in:
Laurent Destailleur 2018-02-03 17:32:38 +01:00
parent 12aec8f806
commit 833c7685e1
4 changed files with 46 additions and 20 deletions

View File

@ -2,6 +2,16 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 8.0.0 compared to 7.0.0 *****
WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from
'doaction' into 'sendMail'.
***** ChangeLog for 7.0.0 compared to 6.0.5 *****
For users:
NEW: When payment is registered, PDF of invoices are also regenerated so payments

View File

@ -106,7 +106,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$subject='';$actionmsg='';$actionmsg2='';
if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail");
$langs->load('mails');
if (is_object($object))
@ -321,6 +320,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Feature to push mail sent into Sent folder
/* This code must be now included into the hook mail, method sendMailAfter
if (! empty($conf->dolimail->enabled))
{
$mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
@ -329,7 +329,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{
$mbid = $mailfromid[1];
/*IMAP Postbox*/
// IMAP Postbox
$mailboxconfig = new IMAP($db);
$mailboxconfig->fetch($mbid);
if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
@ -361,6 +361,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
}
*/
// Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
@ -393,7 +394,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$result=$mailfile->sendfile();
if ($result)
{
// FIXME This must be moved into the trigger for action $trigger_name
// Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
/*
if (! empty($conf->dolimail->enabled))
{
$mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ?
@ -411,7 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs');
else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings');
}
}
}*/
// Initialisation of datas
if (is_object($object))
@ -446,12 +448,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// 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:''));
$moreparam='';
if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
exit;
}
else

View File

@ -482,7 +482,7 @@ class CMailFile
/**
* Send mail that was prepared by constructor
* Send mail that was prepared by constructor.
*
* @return boolean True if mail sent, false otherwise
*/
@ -499,15 +499,21 @@ class CMailFile
{
require_once DOL_DOCUMENT_ROOT . '/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))
$hookmanager->initHooks(array('mail'));
$parameters=array(); $action='';
$reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = "Error in hook maildao doactions " . $reshook;
$this->error = "Error in hook maildao sendMail " . $reshook;
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
return $reshook;
}
if ($reshook == 1) // Hook replace standard code
{
return true;
}
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=10;
@ -760,13 +766,21 @@ class CMailFile
}
else
{
// Send mail method not correctly defined
// --------------------------------------
return 'Bad value for sendmode';
}
$parameters=array(); $action='';
$reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = "Error in hook maildao sendMailAfter " . $reshook;
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
return $reshook;
}
}
else
{

View File

@ -139,6 +139,9 @@ class HookManager
'addMoreMassActions',
'addSearchEntry',
'addStatisticLine',
'createDictionaryFieldList',
'editDictionaryFieldlist',
'getFormMail',
'deleteFile',
'doActions',
'doMassActions',
@ -175,10 +178,9 @@ class HookManager
'formatEvent',
'printObjectLine',
'printObjectSubLine',
'createDictionaryFieldList',
'editDictionaryFieldlist',
'getFormMail',
'showLinkToObjectBlock'
'showLinkToObjectBlock',
'sendMail',
'sendMailAfter'
)
)) $hooktype='addreplace';