From 3544b38ab9edb30a9601e251bc89336da3f67ea6 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 17 Aug 2009 18:24:26 +0000 Subject: [PATCH] - Improvements to the history log for large text fields SVN:trunk[91] --- core/cmdbchangeop.class.inc.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index 05da24db5..aadbc656d 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/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; }