FIX add notification hook to allow external module trigger (#25506)

This commit is contained in:
Florent Poinsaut 2023-07-31 01:54:49 +02:00 committed by GitHub
parent e2915d2979
commit cdc8bc1b6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,10 +66,25 @@ class InterfaceNotification extends DolibarrTriggers
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
global $hookmanager;
if (empty($conf->notification) || !isModEnabled('notification')) {
return 0; // Module not active, we do nothing
}
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('notification'));
$reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action);
if (empty($reshook)) {
if (!empty($hookmanager->resArray['arrayofnotifsupported'])) {
$this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']);
}
}
// If the trigger code is not managed by the Notification module
if (!in_array($action, $this->listofmanagedevents)) {
return 0;
@ -83,7 +98,6 @@ class InterfaceNotification extends DolibarrTriggers
return 1;
}
/**
* Return list of events managed by notification module
*