mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 21:48:45 +02:00
N°6212 - Mirror Target class on Trigger, so it can be displayed in complementary_name
This commit is contained in:
@@ -95,8 +95,29 @@ if (!class_exists('StructureInstaller'))
|
||||
*/
|
||||
public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
|
||||
{
|
||||
if (version_compare($sPreviousVersion, '3.0.0', '<'))
|
||||
{
|
||||
// Search for existing TriggerOnObject where the Trigger string triggering_class is empty and set them 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');
|
||||
$sTableToRead = MetaModel::DBGetTable('TriggerOnObject', 'target_class');
|
||||
$oAttDefToSet = MetaModel::GetAttributeDef('Trigger', 'triggering_class');
|
||||
$oAttDefToRead = MetaModel::GetAttributeDef('TriggerOnObject', 'target_class');
|
||||
|
||||
$aColumnsToSets = array_keys($oAttDefToSet->GetSQLColumns());
|
||||
$sColumnToSet = $aColumnsToSets[0]; // We know that a string has only one column
|
||||
$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);
|
||||
CMDBSource::Query($sRepair);
|
||||
$iNbProcessed = CMDBSource::AffectedRows();
|
||||
SetupLog::Info("| | ".$iNbProcessed." triggers processed.");
|
||||
}
|
||||
|
||||
// Add default configuration, so Persons are notified if mentioned on any Caselog
|
||||
if (version_compare($sPreviousVersion, '3.0.0', '<')) {
|
||||
SetupLog::Info("Adding default triggers/action for Person objects mentions. All DM classes with at least 1 log attribute will be concerned...");
|
||||
|
||||
$sPersonClass = 'Person';
|
||||
@@ -172,7 +193,7 @@ if (!class_exists('StructureInstaller'))
|
||||
// Build the corresponding action and link it to the triggers
|
||||
if (count($aCreatedTriggerIds) > 0) {
|
||||
$oAction = MetaModel::NewObject('ActionEmail');
|
||||
$oAction->Set('name', 'Email mentioned person');
|
||||
$oAction->Set('name', 'Notification to persons mentioned in case logs');
|
||||
$oAction->Set('status', 'enabled');
|
||||
$oAction->Set('from', '$current_contact->email$');
|
||||
$oAction->Set('to', 'SELECT Person WHERE id = :mentioned->id');
|
||||
|
||||
Reference in New Issue
Block a user