From b10b894b24e2b7e7d1ae5133e08e9bc0388aae9d Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 27 Nov 2012 13:44:47 +0000 Subject: [PATCH] Protects the display of the history against renmaed/removed attributes. SVN:trunk[2462] --- core/cmdbchangeop.class.inc.php | 60 +++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index 2017fd8b8..1c27895bb 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/core/cmdbchangeop.class.inc.php @@ -286,8 +286,16 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); - $sAttName = $oAttDef->GetLabel(); + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) + { + $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); + $sAttName = $oAttDef->GetLabel(); + } + else + { + // The attribute was renamed or removed from the object ? + $sAttName = $this->Get('attcode'); + } $oPrevDoc = $this->Get('prevdata'); $sDocView = $oPrevDoc->GetAsHtml(); $sDocView .= "
".Dict::Format('UI:OpenDocumentInNewWindow_',$oPrevDoc->GetDisplayLink(get_class($this), $this->GetKey(), 'prevdata')).", \n"; @@ -342,8 +350,16 @@ class CMDBChangeOpSetAttributeOneWayPassword extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); - $sAttName = $oAttDef->GetLabel(); + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) + { + $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); + $sAttName = $oAttDef->GetLabel(); + } + else + { + // The attribute was renamed or removed from the object ? + $sAttName = $this->Get('attcode'); + } $sResult = Dict::Format('Change:AttName_Changed', $sAttName); } return $sResult; @@ -394,8 +410,16 @@ class CMDBChangeOpSetAttributeEncrypted extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); - $sAttName = $oAttDef->GetLabel(); + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) + { + $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); + $sAttName = $oAttDef->GetLabel(); + } + else + { + // The attribute was renamed or removed from the object ? + $sAttName = $this->Get('attcode'); + } $sPrevString = $this->Get('prevstring'); $sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevString); } @@ -449,8 +473,16 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); - $sAttName = $oAttDef->GetLabel(); + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) + { + $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); + $sAttName = $oAttDef->GetLabel(); + } + else + { + // The attribute was renamed or removed from the object ? + $sAttName = $this->Get('attcode'); + } $sTextView = '
'.$this->GetAsHtml('prevdata').'
'; //$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata'); @@ -509,8 +541,16 @@ class CMDBChangeOpSetAttributeCaseLog extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); - $sAttName = $oAttDef->GetLabel(); + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) + { + $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); + $sAttName = $oAttDef->GetLabel(); + } + else + { + // The attribute was renamed or removed from the object ? + $sAttName = $this->Get('attcode'); + } $sResult = Dict::Format('Change:AttName_EntryAdded', $sAttName); } return $sResult;