mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 09:38:48 +02:00
N°6212 - Report Target class info on Trigger, so it can be displayed in complementary_name
This commit is contained in:
@@ -36,7 +36,7 @@ abstract class Trigger extends cmdbAbstractObject
|
||||
"category" => "grant_by_profile,core/cmdb",
|
||||
"key_type" => "autoincrement",
|
||||
"name_attcode" => "description",
|
||||
"complementary_name_attcode" => array('finalclass', 'triggering_class'),
|
||||
"complementary_name_attcode" => array('finalclass', 'complement'),
|
||||
"state_attcode" => "",
|
||||
"reconc_keys" => array('description'),
|
||||
"db_table" => "priv_trigger",
|
||||
@@ -51,12 +51,12 @@ abstract class Trigger extends cmdbAbstractObject
|
||||
array("linked_class" => "lnkTriggerAction", "ext_key_to_me" => "trigger_id", "ext_key_to_remote" => "action_id", "allowed_values" => null, "count_min" => 1, "count_max" => 0, "depends_on" => array())));
|
||||
$aTags = ContextTag::GetTags();
|
||||
MetaModel::Init_AddAttribute(new AttributeEnumSet("context", array("allowed_values" => null, "possible_values" => new ValueSetEnumPadded($aTags), "sql" => "context", "depends_on" => array(), "is_null_allowed" => true, "max_items" => 12)));
|
||||
// "triggering_class" is a computed field, fed by TriggerOnObject::ComputeValues, so it can be displayed in complementary_name
|
||||
MetaModel::Init_AddAttribute(new AttributeString("triggering_class", array("allowed_values" => null, "sql" => "triggering_class", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
|
||||
// "complement" is a computed field, fed by Trigger sub-classes, in general in ComputeValues method, for eg. the TriggerOnObject fed it with target_class info
|
||||
MetaModel::Init_AddAttribute(new AttributeString("complement", array("allowed_values" => null, "sql" => "complement", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
|
||||
|
||||
// Display lists
|
||||
MetaModel::Init_SetZListItems('details', array('finalclass', 'description', 'context', 'action_list', 'triggering_class')); // Attributes to be displayed for the complete details
|
||||
MetaModel::Init_SetZListItems('list', array('finalclass', 'triggering_class')); // Attributes to be displayed for a list
|
||||
MetaModel::Init_SetZListItems('details', array('finalclass', 'description', 'context', 'action_list', 'complement')); // Attributes to be displayed for the complete details
|
||||
MetaModel::Init_SetZListItems('list', array('finalclass', 'complement')); // Attributes to be displayed for a list
|
||||
// Search criteria
|
||||
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
|
||||
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
|
||||
@@ -208,8 +208,12 @@ abstract class TriggerOnObject extends Trigger
|
||||
public function ComputeValues()
|
||||
{
|
||||
parent::ComputeValues();
|
||||
// Copy the "triggering class name" in parent field, so it can be used in complementary_name of Trigger
|
||||
$this->Set('triggering_class', $this->Get('target_class'));
|
||||
|
||||
// Complementary name of a Trigger is manually built
|
||||
// - the Trigger finalclass code not translated
|
||||
// - an hardcoded text in english
|
||||
// - the target class code not translated for TriggerOnObject subclasses
|
||||
$this->Set('complement', 'class restriction: '.$this->Get('target_class'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -95,13 +95,13 @@ if (!class_exists('StructureInstaller'))
|
||||
*/
|
||||
public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
|
||||
{
|
||||
// Search for existing TriggerOnObject where the Trigger string triggering_class is empty and set them with target_class field value
|
||||
// Search for existing TriggerOnObject where the Trigger string complement is empty and fed it with target_class field value
|
||||
if (version_compare($sPreviousVersion, '3.1.0', '<')) {
|
||||
SetupLog::Info("| Feed computed field triggering_class on existing Triggers.");
|
||||
|
||||
$sTableToSet = MetaModel::DBGetTable('Trigger', 'triggering_class');
|
||||
$sTableToSet = MetaModel::DBGetTable('Trigger', 'complement');
|
||||
$sTableToRead = MetaModel::DBGetTable('TriggerOnObject', 'target_class');
|
||||
$oAttDefToSet = MetaModel::GetAttributeDef('Trigger', 'triggering_class');
|
||||
$oAttDefToSet = MetaModel::GetAttributeDef('Trigger', 'complement');
|
||||
$oAttDefToRead = MetaModel::GetAttributeDef('TriggerOnObject', 'target_class');
|
||||
|
||||
$aColumnsToSets = array_keys($oAttDefToSet->GetSQLColumns());
|
||||
@@ -109,8 +109,8 @@ if (!class_exists('StructureInstaller'))
|
||||
$aColumnsToReads = array_keys($oAttDefToRead->GetSQLColumns());
|
||||
$sColumnToRead = $aColumnsToReads[0]; // We know that a string has only one column
|
||||
|
||||
$sRepair = "UPDATE `$sTableToSet` JOIN `$sTableToRead` ON `$sTableToSet`.id = `$sTableToRead`.id SET `$sTableToSet`.`$sColumnToSet` = `$sTableToRead`.`$sColumnToRead` WHERE `$sTableToSet`.`$sColumnToSet` = ''";
|
||||
SetupLog::Debug("| | Query: ".$sRepair);
|
||||
$sRepair = "UPDATE $sTableToSet JOIN $sTableToRead ON $sTableToSet.id = $sTableToRead.id SET $sTableToSet.$sColumnToSet = CONCAT('class restriction: ',$sTableToRead.$sColumnToRead) WHERE $sTableToSet.$sColumnToSet = ''";
|
||||
SetupLog::Debug(" | | Query: ".$sRepair);
|
||||
CMDBSource::Query($sRepair);
|
||||
$iNbProcessed = CMDBSource::AffectedRows();
|
||||
SetupLog::Info("| | ".$iNbProcessed." triggers processed.");
|
||||
|
||||
@@ -579,19 +579,19 @@ While editing, click on the magnifier to get pertinent examples',
|
||||
//
|
||||
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
'Class:Trigger' => 'Trigger',
|
||||
'Class:Trigger+' => 'Custom event handler',
|
||||
'Class:Trigger/ComplementaryName' => '%1$s, class restriction: %2$s',
|
||||
'Class:Trigger/Attribute:description' => 'Description',
|
||||
'Class:Trigger/Attribute:description+' => 'one line description',
|
||||
'Class:Trigger/Attribute:action_list' => 'Triggered actions',
|
||||
'Class:Trigger/Attribute:action_list+' => 'Actions performed when the trigger is activated',
|
||||
'Class:Trigger/Attribute:finalclass' => 'Trigger sub-class',
|
||||
'Class:Trigger/Attribute:finalclass+' => 'Name of the final class',
|
||||
'Class:Trigger/Attribute:context' => 'Context',
|
||||
'Class:Trigger/Attribute:context+' => 'Context to allow the trigger to start',
|
||||
'Class:Trigger/Attribute:triggering_class' => 'Triggering class',
|
||||
'Class:Trigger/Attribute:triggering_class+' => 'Class triggering, if applicable for this type of trigger',
|
||||
'Class:Trigger' => 'Trigger',
|
||||
'Class:Trigger+' => 'Custom event handler',
|
||||
'Class:Trigger/ComplementaryName' => '%1$s, %2$s',
|
||||
'Class:Trigger/Attribute:description' => 'Description',
|
||||
'Class:Trigger/Attribute:description+' => 'one line description',
|
||||
'Class:Trigger/Attribute:action_list' => 'Triggered actions',
|
||||
'Class:Trigger/Attribute:action_list+' => 'Actions performed when the trigger is activated',
|
||||
'Class:Trigger/Attribute:finalclass' => 'Trigger sub-class',
|
||||
'Class:Trigger/Attribute:finalclass+' => 'Name of the final class',
|
||||
'Class:Trigger/Attribute:context' => 'Context',
|
||||
'Class:Trigger/Attribute:context+' => 'Context to allow the trigger to start',
|
||||
'Class:Trigger/Attribute:complement' => 'Additional information',
|
||||
'Class:Trigger/Attribute:complement+' => 'Further information as provided in english, by this trigger',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -580,19 +580,19 @@ En édition, cliquez sur la loupe pour obtenir des exemples pertinents.',
|
||||
//
|
||||
|
||||
Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Class:Trigger' => 'Déclencheur',
|
||||
'Class:Trigger+' => '',
|
||||
'Class:Trigger/ComplementaryName' => '%1$s, limité à la classe : %2$s',
|
||||
'Class:Trigger/Attribute:description' => 'Description',
|
||||
'Class:Trigger/Attribute:description+' => '',
|
||||
'Class:Trigger/Attribute:action_list' => 'Actions déclenchées',
|
||||
'Class:Trigger/Attribute:action_list+' => 'Actions effectuées quand le déclencheur est activé',
|
||||
'Class:Trigger/Attribute:finalclass' => 'Sous-classe de Déclencheur',
|
||||
'Class:Trigger/Attribute:finalclass+' => 'Nom de la classe instanciable',
|
||||
'Class:Trigger/Attribute:context' => 'Contexte',
|
||||
'Class:Trigger/Attribute:context+' => 'Contexte de déclenchement',
|
||||
'Class:Trigger/Attribute:triggering_class' => 'Classe concernée',
|
||||
'Class:Trigger/Attribute:triggering_class+' => 'Classe concernée par ce déclencheur',
|
||||
'Class:Trigger' => 'Déclencheur',
|
||||
'Class:Trigger+' => '',
|
||||
'Class:Trigger/ComplementaryName' => '%1$s, %2$s',
|
||||
'Class:Trigger/Attribute:description' => 'Description',
|
||||
'Class:Trigger/Attribute:description+' => '',
|
||||
'Class:Trigger/Attribute:action_list' => 'Actions déclenchées',
|
||||
'Class:Trigger/Attribute:action_list+' => 'Actions effectuées quand le déclencheur est activé',
|
||||
'Class:Trigger/Attribute:finalclass' => 'Sous-classe de Déclencheur',
|
||||
'Class:Trigger/Attribute:finalclass+' => 'Nom de la classe instanciable',
|
||||
'Class:Trigger/Attribute:context' => 'Contexte',
|
||||
'Class:Trigger/Attribute:context+' => 'Contexte de déclenchement',
|
||||
'Class:Trigger/Attribute:complement' => 'Information complémentaire',
|
||||
'Class:Trigger/Attribute:complement+' => 'Détails en anglais, fourni par ce type de déclencheur',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user