function Update($ID, $arFields, $bSetSource = false)
	{
		global $DB;

		$ID = IntVal($ID);
		if ($ID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LC_WRONG_PARAMETER_ID"), "ERROR_NO_ID");
			return false;
		}

		if ($bSetSource)
		{
			if (strlen($arFields["EVENT_ID"]) > 0)
			{
				$arCommentEvent = CSocNetLogTools::FindLogCommentEventByID($arFields["EVENT_ID"]);
				if (
					!$arCommentEvent
					|| !array_key_exists("UPDATE_CALLBACK", $arCommentEvent)
					|| !is_callable($arCommentEvent["UPDATE_CALLBACK"])
				)
				{
					$bSetSource = false;
				}
			}

			if (
				!isset($arFields["SOURCE_ID"])
				|| !isset($arFields["LOG_ID"])
			)
			{
				$rsRes = CSocNetLogComments::GetList(
					array(),
					array("ID" => $ID),
					false,
					false,
					array("LOG_ID", "SOURCE_ID")
				);
				if ($arRes = $rsRes->Fetch())
				{
					$arFields["SOURCE_ID"] = $arRes["SOURCE_ID"];
					$arFields["LOG_ID"] = $arRes["LOG_ID"];
				}
			}
			
			if (!isset($arFields["SOURCE_ID"]))
			{
				$bSetSource = false;
			}
		}

		$arFields1 = array();
		foreach ($arFields as $key => $value)
		{
			if (substr($key, 0, 1) == "=")
			{
				$arFields1[substr($key, 1)] = $value;
				unset($arFields[$key]);
			}
		}

		if ($bSetSource)
		{
			$arSource = CSocNetLogComments::SetSource($arFields, "UPDATE");

			if (
				isset($arSource["NO_SOURCE"]) 
				&& $arSource["NO_SOURCE"] == "Y"
			)
			{
				$bSetSource = false;
			}
			elseif (
				is_array($arSource)
				&& (
					isset($arSource["ERROR"])
					&& !empty($arSource["ERROR"])
				)
			)
			{
				return array(
					"ID" => false,
					"MESSAGE" => $arSource["ERROR"]
				);
			}
			else
			{
				if (
					isset($arSource["MESSAGE"]) 
					&& strlen($arSource["MESSAGE"]) > 0
				)
				{
					$arFields["MESSAGE"] = $arSource["MESSAGE"];
				}

				if (
					isset($arSource["TEXT_MESSAGE"]) 
					&& strlen($arSource["TEXT_MESSAGE"]) > 0
				)
				{
					$arFields["TEXT_MESSAGE"] = $arSource["TEXT_MESSAGE"];
				}

				if (
					isset($arSource["UF"]) 
					&& isset($arSource["UF"]["FILE"])
				)
				{
					if (!is_array($arSource["UF"]["FILE"]))
					{
						$arSource["UF"]["FILE"] = array($arSource["UF"]["FILE"]);
					}

					$arFields["UF_SONET_COM_FILE"] = $arSource["UF"]["FILE"];
				}

				if (
					isset($arSource["UF"]) 
					&& isset($arSource["UF"]["DOC"])
				)
				{
					if (!is_array($arSource["UF"]["DOC"]))
					{
						$arSource["UF"]["DOC"] = array($arSource["UF"]["DOC"]);
					}

					$arFields["UF_SONET_COM_DOC"] = $arSource["UF"]["DOC"];
				}
			}
		}

		if (!CSocNetLogComments::CheckFields("UPDATE", $arFields, $ID))
		{
			return false;
		}

		if (
			!$bSetSource
			|| (
				is_array($arSource)
				&& (
					!isset($arSource["ERROR"])
					|| empty($arSource["ERROR"])
				)
			)
		)
		{
			$strUpdate = $DB->PrepareUpdate("b_sonet_log_comment", $arFields);

			foreach ($arFields1 as $key => $value)
			{
				if (strlen($strUpdate) > 0)
					$strUpdate .= ", ";
				$strUpdate .= $key."=".$value." ";
			}

			if (strlen($strUpdate) > 0)
			{
				$strSql =
					"UPDATE b_sonet_log_comment SET ".
					"	".$strUpdate." ".
					"WHERE ID = ".$ID." ";
				$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);

				$GLOBALS["USER_FIELD_MANAGER"]->Update("SONET_COMMENT", $ID, $arFields);

				if(defined("BX_COMP_MANAGED_CACHE"))
				{
					$GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_COMMENT_".$ID);
				}
			}
			elseif (!$GLOBALS["USER_FIELD_MANAGER"]->Update("SONET_COMMENT", $ID, $arFields))
			{
				$ID = False;
			}
		}
		else
		{
			$ID = False;
		}

		return $ID;
	}
 function Update($ID, $arFields)
 {
     global $DB;
     $ID = IntVal($ID);
     if ($ID <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LC_WRONG_PARAMETER_ID"), "ERROR_NO_ID");
         return false;
     }
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSocNetLogComments::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_sonet_log_comment", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (strlen($strUpdate) > 0) {
         $strSql = "UPDATE b_sonet_log_comment SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_COMMENT_" . $ID);
         }
     } else {
         $ID = False;
     }
     return $ID;
 }