Browse Source

N.519 REST/JSON Add a comment in pure text into the case log (only for add_item/items syntaxes, use format="text")

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4619 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 years ago
parent
commit
c2b6f681d6
1 changed files with 10 additions and 6 deletions
  1. 10 6
      core/ormcaselog.class.inc.php

+ 10 - 6
core/ormcaselog.class.inc.php

@@ -1,5 +1,5 @@
 <?php
 <?php
-// Copyright (C) 2010-2016 Combodo SARL
+// Copyright (C) 2010-2017 Combodo SARL
 //
 //
 //   This file is part of iTop.
 //   This file is part of iTop.
 //
 //
@@ -23,7 +23,7 @@ define('CASELOG_SEPARATOR', "\n".'========== %1$s : %2$s (%3$d) ============'."\
 /**
 /**
  * Class to store a "case log" in a structured way, keeping track of its successive entries
  * Class to store a "case log" in a structured way, keeping track of its successive entries
  *  
  *  
- * @copyright   Copyright (C) 2010-2016 Combodo SARL
+ * @copyright   Copyright (C) 2010-2017 Combodo SARL
  * @license     http://opensource.org/licenses/AGPL-3.0
  * @license     http://opensource.org/licenses/AGPL-3.0
  */
  */
 class ormCaseLog {
 class ormCaseLog {
@@ -568,8 +568,6 @@ class ormCaseLog {
 
 
 	public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
 	public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
 	{
 	{
-		$sText = HTMLSanitizer::Sanitize(isset($oJson->message) ? $oJson->message : '');
-
 		if (isset($oJson->user_id))
 		if (isset($oJson->user_id))
 		{
 		{
 			if (!UserRights::IsAdministrator())
 			if (!UserRights::IsAdministrator())
@@ -616,10 +614,16 @@ class ormCaseLog {
 		}
 		}
 		else
 		else
 		{
 		{
-			// TODO: what is the default format ? text ?
+			// The default is HTML
 			$sFormat = 'html';
 			$sFormat = 'html';
 		}
 		}
-		
+
+		$sText = isset($oJson->message) ? $oJson->message : '';
+		if ($sFormat == 'html')
+		{
+			$sText = HTMLSanitizer::Sanitize($sText);
+		}
+
 		$sDate = date(AttributeDateTime::GetInternalFormat(), $iDate);
 		$sDate = date(AttributeDateTime::GetInternalFormat(), $iDate);
 
 
 		$sSeparator = sprintf(CASELOG_SEPARATOR, $sDate, $sOnBehalfOf, $iUserId);
 		$sSeparator = sprintf(CASELOG_SEPARATOR, $sDate, $sOnBehalfOf, $iUserId);