From 405b1b8e6f9eefb5caaf1dbed5a8e50b8ffca6cd Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Nov 2018 14:36:15 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B0917=20-=20Trigger=20on=20object=20update?= =?UTF-8?q?:=20limit=20the=20fields=20proposed=20to=20the=20ones=20that=20?= =?UTF-8?q?can=20be=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/attributedef.class.inc.php | 23 ++++++++++++++++++++--- core/trigger.class.inc.php | 2 +- setup/compiler.class.inc.php | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 368a4cdec..aaa6403ea 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -9156,7 +9156,7 @@ class AttributeClassAttCodeSet extends AttributeSet static public function ListExpectedParams() { - return array_merge(parent::ListExpectedParams(), array('class_field', 'attribute_definition_list')); + return array_merge(parent::ListExpectedParams(), array('class_field', 'attribute_definition_list', 'attribute_definition_exclusion_list')); } public function GetMaxSize() @@ -9181,6 +9181,17 @@ class AttributeClassAttCodeSet extends AttributeSet { $aAllAttributes = MetaModel::GetAttributesList($sClass); } + $sAttDefExclusionList = $this->Get('attribute_definition_exclusion_list'); + $aExcludeDefs = array(); + if (!empty($sAttDefExclusionList)) + { + foreach(explode(',', $sAttDefExclusionList) as $sAttDefName) + { + $sAttDefName = trim($sAttDefName); + $aExcludeDefs[$sAttDefName] = $sAttDefName; + } + } + $sAttDefList = $this->Get('attribute_definition_list'); if (!empty($sAttDefList)) { @@ -9193,7 +9204,8 @@ class AttributeClassAttCodeSet extends AttributeSet foreach($aAllAttributes as $sAttCode) { $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); - if (isset($aAllowedDefs[get_class($oAttDef)])) + $sAttDef = get_class($oAttDef); + if (isset($aAllowedDefs[$sAttDef]) && !isset($aExcludeDefs[$sAttDef])) { $aAllowedAttributes[$sAttCode] = $sAttCode.' ('.MetaModel::GetLabel($sClass, $sAttCode).')'; } @@ -9203,7 +9215,12 @@ class AttributeClassAttCodeSet extends AttributeSet { foreach($aAllAttributes as $sAttCode) { - $aAllowedAttributes[$sAttCode] = $sAttCode.' ('.MetaModel::GetLabel($sClass, $sAttCode).')'; + $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); + $sAttDef = get_class($oAttDef); + if (!isset($aExcludeDefs[$sAttDef])) + { + $aAllowedAttributes[$sAttCode] = $sAttCode.' ('.MetaModel::GetLabel($sClass, $sAttCode).')'; + } } } return $aAllowedAttributes; diff --git a/core/trigger.class.inc.php b/core/trigger.class.inc.php index 1853ac35d..e926455cf 100644 --- a/core/trigger.class.inc.php +++ b/core/trigger.class.inc.php @@ -461,7 +461,7 @@ class TriggerOnObjectUpdate extends TriggerOnObject ); MetaModel::Init_Params($aParams); MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeClassAttCodeSet('target_attcodes', array("allowed_values" => null, "class_field" => "target_class", "sql" => "target_attcodes", "default_value" => null, "is_null_allowed" => true, "max_items" => 20, "min_items" => 0, "attribute_definition_list" => null, "depends_on" => array('target_class')))); + MetaModel::Init_AddAttribute(new AttributeClassAttCodeSet('target_attcodes', array("allowed_values" => null, "class_field" => "target_class", "sql" => "target_attcodes", "default_value" => null, "is_null_allowed" => true, "max_items" => 20, "min_items" => 0, "attribute_definition_exclusion_list" => "AttributeDashboard,AttributeExternalField,AttributeFinalClass,AttributeFriendlyName,AttributeObsolescenceDate,AttributeObsolescenceFlag", "attribute_definition_list" => null, "depends_on" => array('target_class')))); // Display lists MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'target_attcodes', 'action_list')); // Attributes to be displayed for the complete details diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 9fc76e068..b3eba1196 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -1491,6 +1491,8 @@ EOF $aParameters['class_field'] = $this->GetMandatoryPropString($oField, 'class_field'); // List of AttributeDefinition Classes to filter class_field (empty means all) $aParameters['attribute_definition_list'] = $this->GetPropString($oField, 'attribute_definition_list', ''); + // Exclusion list of AttributeDefinition Classes to filter class_field (empty means no exclusion) + $aParameters['attribute_definition_exclusion_list'] = $this->GetPropString($oField, 'attribute_definition_exclusion_list', ''); } elseif ($sAttType == 'AttributeQueryAttCodeSet') {