N°3508 - Add warning message on save if action has no trigger attached

This commit is contained in:
Molkobain
2021-12-04 19:43:51 +01:00
parent 9f0e2c0a3a
commit a5bf059e23
17 changed files with 49 additions and 0 deletions

View File

@@ -118,6 +118,39 @@ abstract class Action extends cmdbAbstractObject
return false;
}
}
/**
* @inheritDoc
* @since 3.0.0
*/
public function AfterInsert()
{
parent::AfterInsert();
$this->DoCheckIfHasTrigger();
}
/**
* @inheritDoc
* @since 3.0.0
*/
public function AfterUpdate()
{
parent::AfterUpdate();
$this->DoCheckIfHasTrigger();
}
/**
* Check if the Action has at least 1 trigger linked. Otherwise, it adds a warning.
* @return void
* @since 3.0.0
*/
protected function DoCheckIfHasTrigger()
{
$oTriggersSet = $this->Get('trigger_list');
if ($oTriggersSet->Count() === 0) {
$this->m_aCheckWarnings[] = Dict::S('Action:WarningNoTriggerLinked');
}
}
}
/**

View File

@@ -501,6 +501,7 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', array(
'Class:Action/Attribute:trigger_list+' => 'Triggery spojené s touto akcí',
'Class:Action/Attribute:finalclass' => 'Typ',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -499,6 +499,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array(
'Class:Action/Attribute:trigger_list+' => '',
'Class:Action/Attribute:finalclass' => 'Type',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -498,6 +498,7 @@ Dict::Add('DE DE', 'German', 'Deutsch', array(
'Class:Action/Attribute:trigger_list+' => 'Trigger, die mit dieser Aktion verknüpft sind',
'Class:Action/Attribute:finalclass' => 'Typ',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -499,6 +499,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:Action/Attribute:trigger_list+' => 'Triggers linked to this action',
'Class:Action/Attribute:finalclass' => 'Action sub-class',
'Class:Action/Attribute:finalclass+' => 'Name of the final class',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.',
));
//

View File

@@ -500,6 +500,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
'Class:Action/Attribute:trigger_list+' => 'Disparadores Asociados a esta Acción',
'Class:Action/Attribute:finalclass' => 'Clase',
'Class:Action/Attribute:finalclass+' => 'Clase',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -497,6 +497,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:Action/Attribute:trigger_list+' => '',
'Class:Action/Attribute:finalclass' => 'Sous-classe d\'Action',
'Class:Action/Attribute:finalclass+' => 'Nom de la classe instanciable',
'Action:WarningNoTriggerLinked' => 'Attention, aucun déclencheur n\'est associé à l\'action. Elle ne sera pas active tant qu\'elle n\'en aura pas au moins 1.',
));
//

View File

@@ -497,6 +497,7 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array(
'Class:Action/Attribute:trigger_list+' => '',
'Class:Action/Attribute:finalclass' => 'Típus',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -499,6 +499,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array(
'Class:Action/Attribute:trigger_list+' => 'Triggers colleagati a questa azione',
'Class:Action/Attribute:finalclass' => 'Tipo',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -497,6 +497,7 @@ Dict::Add('JA JP', 'Japanese', '日本語', array(
'Class:Action/Attribute:trigger_list+' => 'このアクションにリンクされたトリガー',
'Class:Action/Attribute:finalclass' => 'タイプ',
'Class:Action/Attribute:finalclass+' => 'タイプ',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -505,6 +505,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array(
'Class:Action/Attribute:trigger_list+' => 'Triggers gelinkt aan deze actie',
'Class:Action/Attribute:finalclass' => 'Type',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -499,6 +499,7 @@ Dict::Add('PL PL', 'Polish', 'Polski', array(
'Class:Action/Attribute:trigger_list+' => 'Wyzwalacze powiązane z działaniem',
'Class:Action/Attribute:finalclass' => 'Podklasa działania',
'Class:Action/Attribute:finalclass+' => 'Nazwa ostatniej klasy',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -499,6 +499,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
'Class:Action/Attribute:trigger_list+' => 'Gatilhos ligados a esta ação',
'Class:Action/Attribute:finalclass' => 'Tipo',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -486,6 +486,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', array(
'Class:Action/Attribute:trigger_list+' => 'Триггеры, которые запускают данное действие',
'Class:Action/Attribute:finalclass' => 'Тип',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -496,6 +496,7 @@ Dict::Add('SK SK', 'Slovak', 'Slovenčina', array(
'Class:Action/Attribute:trigger_list+' => '',
'Class:Action/Attribute:finalclass' => 'Typ',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -507,6 +507,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
'Class:Action/Attribute:trigger_list+' => 'İşleme bağlı tetikleyici',
'Class:Action/Attribute:finalclass' => 'Tip',
'Class:Action/Attribute:finalclass+' => '',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//

View File

@@ -498,6 +498,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
'Class:Action/Attribute:trigger_list+' => '该操作关联的触发器',
'Class:Action/Attribute:finalclass' => 'Action sub-class',
'Class:Action/Attribute:finalclass+' => 'Name of the final class',
'Action:WarningNoTriggerLinked' => 'Warning, no trigger is linked to the action. It will not be active until it has at least 1.~~',
));
//