[New] Add sendMail hook in subscription

Added sendMail hook in subscription, before a mail is sent to confirm a
subscription. It makes it more flexible for modules to interact with it.
This commit is contained in:
Corentin Giroud-Argoud 2020-12-16 10:47:28 +01:00
parent a5b86f74ce
commit 4df0efa43d

View File

@ -300,6 +300,23 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
if (!$error) { if (!$error) {
// Send confirmation Email // Send confirmation Email
if ($object->email && $sendalsoemail) { // $object is 'Adherent' if ($object->email && $sendalsoemail) { // $object is 'Adherent'
$parameters = array(
'datesubscription' => $datesubscription,
'amount' => $amount,
'ccountid' => $accountid,
'operation' => $operation,
'label' => $label,
'num_chq' => $num_chq,
'emetteur_nom' => $emetteur_nom,
'emetteur_banque' => $emetteur_banque,
'datesubend' => $datesubend
);
$reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$subject = ''; $subject = '';
$msg = ''; $msg = '';
@ -352,6 +369,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
} else { } else {
setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs');
} }
}
} else { } else {
setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs');
} }