From cdc8bc1b6f1f86edb547d380be8e29b5c2f808ae Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Mon, 31 Jul 2023 01:54:49 +0200 Subject: [PATCH] FIX add notification hook to allow external module trigger (#25506) --- ...ace_50_modNotification_Notification.class.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 1aa21dbd1ba..23c81df9c9a 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -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 *