Browse Source

- Improvements to the history log for large text fields

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@91 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 16 years ago
parent
commit
327eee53c6
1 changed files with 23 additions and 1 deletions
  1. 23 1
      core/cmdbchangeop.class.inc.php

+ 23 - 1
core/cmdbchangeop.class.inc.php

@@ -201,7 +201,29 @@ class CMDBChangeOpSetAttribute extends CMDBChangeOp
 			$sAttName = $oAttDef->GetLabel();
 			$sNewValue = $this->Get('newvalue');
 			$sOldValue = $this->Get('oldvalue');
-			$sResult = "$sAttName set to $sNewValue (previous value: $sOldValue)";
+			if ( (($oAttDef->GetType() == 'String') || ($oAttDef->GetType() == 'Text')) &&
+				 (strlen($sNewValue) > strlen($sOldValue)) )
+			{
+				// Check if some text was not appended to the field
+				if (substr($sNewValue,0, strlen($sOldValue)) == $sOldValue) // Text added at the end
+				{
+					$sDelta = substr($sNewValue, strlen($sOldValue));
+					$sResult = "$sDelta appended to $sAttName";
+				}
+				else if (substr($sNewValue, -strlen($sOldValue)) == $sOldValue)   // Text added at the beginning
+				{
+					$sDelta = substr($sNewValue, 0, strlen($sNewValue) - strlen($sOldValue));
+					$sResult = "$sDelta appended to $sAttName";
+				}
+				else
+				{
+					$sResult = "$sAttName set to $sNewValue (previous value: $sOldValue)";
+				}
+			}
+			else
+			{
+				$sResult = "$sAttName set to $sNewValue (previous value: $sOldValue)";
+			}
 		}
 		return $sResult;
 	}