Przeglądaj źródła

Protects the display of the history against renmaed/removed attributes.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2462 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 lat temu
rodzic
commit
392f75a117
1 zmienionych plików z 50 dodań i 10 usunięć
  1. 50 10
      core/cmdbchangeop.class.inc.php

+ 50 - 10
core/cmdbchangeop.class.inc.php

@@ -286,8 +286,16 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
 		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');
 			$oPrevDoc = $this->Get('prevdata');
 			$sDocView = $oPrevDoc->GetAsHtml();
 			$sDocView = $oPrevDoc->GetAsHtml();
 			$sDocView .= "<br/>".Dict::Format('UI:OpenDocumentInNewWindow_',$oPrevDoc->GetDisplayLink(get_class($this), $this->GetKey(), 'prevdata')).", \n";
 			$sDocView .= "<br/>".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);
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
 		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);
 			$sResult = Dict::Format('Change:AttName_Changed', $sAttName);
 		}
 		}
 		return $sResult;
 		return $sResult;
@@ -394,8 +410,16 @@ class CMDBChangeOpSetAttributeEncrypted extends CMDBChangeOpSetAttribute
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
 		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');
 			$sPrevString = $this->Get('prevstring');
 			$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevString);
 			$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevString);
 		}
 		}
@@ -449,8 +473,16 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
 		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 = '<div>'.$this->GetAsHtml('prevdata').'</div>';
 			$sTextView = '<div>'.$this->GetAsHtml('prevdata').'</div>';
 
 
 			//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
 			//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
@@ -509,8 +541,16 @@ class CMDBChangeOpSetAttributeCaseLog extends CMDBChangeOpSetAttribute
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		$oMonoObjectSet = new DBObjectSet($oTargetSearch);
 		if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
 		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);
 			$sResult = Dict::Format('Change:AttName_EntryAdded', $sAttName);
 		}
 		}
 		return $sResult;
 		return $sResult;