• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/logcomment.php
  • Класс: BitrixSocialnetworkLivefeedLogComment
  • Вызов: LogComment::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'])
		&& (string)$params['MESSAGE'] !== ''
			? $params['MESSAGE']
			: ''
	);

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

	$module = ($params['MODULE'] ?? 'tasks');
	$logId = $this->getLogId();

	if (!$logId)
	{
		return false;
	}

	$this->setLogId($logId);

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

	$commentEventId = false;

	$providerIntranetNewUser = new IntranetNewUser();
	if (in_array($this->getLogEventId(), $providerIntranetNewUser->getEventId(), true))
	{
		$commentEventId = 'intranet_new_user_comment';
	}

	if (!$commentEventId)
	{
		$providerBitrix24NewUser = new Bitrix24NewUser();
		if (in_array($this->getLogEventId(), $providerBitrix24NewUser->getEventId(), true))
		{
			$commentEventId = 'bitrix24_new_user_comment';
		}
	}

	if (!$commentEventId)
	{
		$providerPhotogalleryAlbum = new PhotogalleryAlbum();
		if (in_array($this->getLogEventId(), $providerPhotogalleryAlbum->getEventId(), true))
		{
			$commentEventId = 'photoalbum_comment';
		}
	}

	if (!$commentEventId)
	{
		$commentEventId = 'data_comment';
	}

	$sonetCommentFields = array(
		"ENTITY_TYPE" => $this->getLogEntityType(),
		"ENTITY_ID" => $this->getLogEntityId(),
		"EVENT_ID" => $commentEventId,
		"MESSAGE" => $message,
		"TEXT_MESSAGE" => $parser->convert4mail($message),
		"MODULE_ID" => $module,
		"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' => $sonetCommentId,
		'sourceCommentId' => $sonetCommentId
	];
}