From 69677954b47cf681cc60f63bcee04dbd85f82dfb Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 23 Feb 2024 18:33:09 +0100 Subject: [PATCH 1/7] =?UTF-8?q?N=C2=B07157=20-=20Change=20way=20to=20pass?= =?UTF-8?q?=20calling=20trigger=20to=20action=20in=20order=20to=20ease=20e?= =?UTF-8?q?xtensibility=20and=20to=20be=20able=20to=20use=20its=20attribut?= =?UTF-8?q?es=20in=20placeholders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/action.class.inc.php | 17 +---------------- core/trigger.class.inc.php | 5 ++++- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/core/action.class.inc.php b/core/action.class.inc.php index 4054e2107a..285c096789 100644 --- a/core/action.class.inc.php +++ b/core/action.class.inc.php @@ -41,12 +41,6 @@ */ abstract class Action extends cmdbAbstractObject { - /** - * @var $oCallingTrigger Trigger|null The trigger that called this action {@see DoExecute} - * @since 3.2.0 - */ - protected ?Trigger $oCallingTrigger = null; - /** * @throws \CoreException * @throws \Exception @@ -276,14 +270,6 @@ public static function Init() // MetaModel::Init_SetZListItems('default_search', array('name')); } - /** - * @inheritDoc - */ - public function DoExecute($oTrigger, $aContextArgs) - { - $this->oCallingTrigger = $oTrigger; - } - /** * @param $sLanguage * @param $sLanguageCode @@ -447,7 +433,7 @@ public static function Init() */ protected function FindRecipients($sRecipAttCode, $aArgs) { - $oTrigger = $this->oCallingTrigger; + $oTrigger = $aArgs['trigger->object()']; $sOQL = $this->Get($sRecipAttCode); if (utils::IsNullOrEmptyString($sOQL)) return ''; @@ -523,7 +509,6 @@ protected function FindRecipients($sRecipAttCode, $aArgs) */ public function DoExecute($oTrigger, $aContextArgs) { - parent::DoExecute($oTrigger, $aContextArgs); if (MetaModel::IsLogEnabledNotification()) { $oLog = new EventNotificationEmail(); diff --git a/core/trigger.class.inc.php b/core/trigger.class.inc.php index 19bb3a7c38..24a8ecb851 100644 --- a/core/trigger.class.inc.php +++ b/core/trigger.class.inc.php @@ -112,6 +112,8 @@ public function DoActivate($aContextArgs) return; } + $aContextArgs['trigger->object()'] = $this; + // Find the related actions $oLinkedActions = $this->Get('action_list'); @@ -121,7 +123,7 @@ public function DoActivate($aContextArgs) $aActionListOrdered[(int) $oLink->Get('order')][] = $oLink; } ksort($aActionListOrdered); - + // Execute actions foreach ($aActionListOrdered as $aActionSubList) { foreach ($aActionSubList as $oLink) /** @var \DBObject $oLink */ { @@ -131,6 +133,7 @@ public function DoActivate($aContextArgs) $oAction = MetaModel::GetObject('Action', $iActionId); if ($oAction->IsActive()) { $oKPI = new ExecutionKPI(); + $aContextArgs['action->object()'] = $oAction; $oAction->DoExecute($this, $aContextArgs); $oKPI->ComputeStatsForExtension($oAction, 'DoExecute'); } From 2b172d6e19d8e3bb4e5677c864a6f6bf5a4c847f Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 23 Feb 2024 18:45:12 +0100 Subject: [PATCH 2/7] =?UTF-8?q?N=C2=B07157=20-=20Fix=20ActioniTopNotificat?= =?UTF-8?q?ion=20friendlyname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/datamodel.core.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/datamodel.core.xml b/core/datamodel.core.xml index 059a3d6273..2f9458acc3 100644 --- a/core/datamodel.core.xml +++ b/core/datamodel.core.xml @@ -106,7 +106,7 @@ - +