CrmEntityComment::add

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CrmEntityComment
  4. add
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/socialnetwork/livefeed/crmentitycomment.php
  • Класс: Bitrix\Crm\Integration\Socialnetwork\Livefeed\CrmEntityComment
  • Вызов: CrmEntityComment::add
public function add($params = array())
{
	global $USER;

	static $parser = null;

	$authorId = (
		isset($params['AUTHOR_ID'])
		&& (int)$params['AUTHOR_ID'] > 0
			? (int)$params['AUTHOR_ID']
			: $USER->getId()
	);

	$message = (string)(
		isset($params['MESSAGE'])
		&& $params['MESSAGE'] <> ''
			? $params['MESSAGE']
			: ''
	);

	if ($message === '')
	{
		return false;
	}

	$logId = $this->getLogId();

	if (!$logId)
	{
		return false;
	}

	$this->setLogId($logId);

	if ($parser === null)
	{
		$parser = new \CTextParser();
	}

	$logFields = $this->getLogFields();

	$sonetCommentFields = array(
		"ENTITY_TYPE" => $this->getLogEntityType(),
		"ENTITY_ID" => $this->getLogEntityId(),
		"EVENT_ID" => $logFields['EVENT_ID'].\CCrmLiveFeedEvent::CommentSuffix,
		"MESSAGE" => $message,
		"TEXT_MESSAGE" => $parser->convert4mail($message),
		"MODULE_ID" => "tasks",
		"LOG_ID" => $logId,
		"RATING_TYPE_ID" => "LOG_COMMENT",
		"USER_ID" => $authorId,
		"=LOG_DATE" => \CDatabase::CurrentTimeFunction(),
	);

	if (!empty($params['SHARE_DEST']))
	{
		$sonetCommentFields['SHARE_DEST'] = $params['SHARE_DEST'];
	}

	if ($sonetCommentId = \CSocNetLogComments::add($sonetCommentFields, false, false))
	{
		\CSocNetLogComments::update($sonetCommentId, array(
			"RATING_ENTITY_ID" => $sonetCommentId
		));
	}

	return $sonetCommentId;
}

Добавить комментарий