mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 09:38:48 +02:00
Fixed bug #231: distinguish between external key (id) and external key (name) for loading fields that are external keys pointing to externla keys! Example: Connected To->Device is to be mapped to the Connected Interface's device NAME whereas Connected To->Device->id is to be mapped to the connected interface's device id
SVN:trunk[747]
This commit is contained in:
@@ -661,7 +661,14 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
{
|
||||
$sExtKeyLabel = MetaModel::GetLabel($sClassName, $oAttDef->GetKeyAttCode());
|
||||
$sRemoteAttLabel = MetaModel::GetLabel($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode());
|
||||
$aHeader[] = $sExtKeyLabel.'->'.$sRemoteAttLabel;
|
||||
$oTargetAttDef = MetaModel::GetAttributeDef($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode());
|
||||
$sSuffix = '';
|
||||
if ($oTargetAttDef->IsExternalKey())
|
||||
{
|
||||
$sSuffix = '->id';
|
||||
}
|
||||
|
||||
$aHeader[] = $sExtKeyLabel.'->'.$sRemoteAttLabel.$sSuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -70,10 +70,16 @@ function GetMappingsForExtKey($sAttCode, AttributeDefinition $oExtKeyAttDef, $bA
|
||||
{
|
||||
if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode))
|
||||
{
|
||||
if ($bAdvanced || !$oTargetAttDef->IsExternalKey())
|
||||
$bExtKey = $oTargetAttDef->IsExternalKey();
|
||||
$sSuffix = '';
|
||||
if ($bExtKey)
|
||||
{
|
||||
$sSuffix = '->id';
|
||||
}
|
||||
if ($bAdvanced || !$bExtKey)
|
||||
{
|
||||
// When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys !
|
||||
$aResult[$sAttCode.'->'.$sTargetAttCode] = $oExtKeyAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel();
|
||||
$aResult[$sAttCode.'->'.$sTargetAttCode] = $oExtKeyAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().$sSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,12 +130,18 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
|
||||
{
|
||||
if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode))
|
||||
{
|
||||
if ($bAdvancedMode || (!$oTargetAttDef->IsExternalKey()))
|
||||
$bExtKey = $oTargetAttDef->IsExternalKey();
|
||||
$sSuffix = '';
|
||||
if ($bExtKey)
|
||||
{
|
||||
$sSuffix = '->id';
|
||||
}
|
||||
if ($bAdvancedMode || !$bExtKey)
|
||||
{
|
||||
|
||||
// When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys !
|
||||
$aChoices[$sAttCode.'->'.$sTargetAttCode] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel();
|
||||
if ((strcasecmp($sFieldName, $aChoices[$sAttCode.'->'.$sTargetAttCode]) == 0) || (strcasecmp($sFieldName, ($sAttCode.'->'.$sTargetAttCode)) == 0) )
|
||||
$aChoices[$sAttCode.'->'.$sTargetAttCode] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().$sSuffix;
|
||||
if ((strcasecmp($sFieldName, $aChoices[$sAttCode.'->'.$sTargetAttCode]) == 0) || (strcasecmp($sFieldName, ($sAttCode.'->'.$sTargetAttCode.$sSuffix)) == 0) )
|
||||
{
|
||||
$sFieldCode = $sAttCode.'->'.$sTargetAttCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user