• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log.php
  • Класс: CAllSocNetLog
  • Вызов: CAllSocNetLog::CounterIncrement
static function CounterIncrement(
	$entityId,
	$eventId = '',
	$entitiesList = false,
	$type = CSocNetLogCounter::TYPE_LOG_ENTRY,
	$forAllAccess = false,
	$userIdToPushList = []
): void
{
	if (
		is_array($entityId)
		&& isset($entityId["ENTITY_ID"])
	)
	{
		$arFields = $entityId;
		$entityId = $arFields["ENTITY_ID"];
		$eventId = (string)($arFields["EVENT_ID"] ?? '');
		$type = ($arFields["TYPE"] ?? CSocNetLogCounter::TYPE_LOG_ENTRY);
		$forAllAccess = ($arFields["FOR_ALL_ACCESS"] ?? false);
		$userIdToPushList = ($arFields["USERS_TO_PUSH"] ?? []);
		$sendToAuthor = (
			isset($arFields['SEND_TO_AUTHOR'])
			&& $arFields['SEND_TO_AUTHOR'] === 'Y'
		);
	}
	else
	{
		$sendToAuthor = false;
	}

	if ((int)$entityId <= 0)
	{
		return;
	}

	if (
		$eventId === "tasks"
		&& !BitrixSocialnetworkComponentHelper::checkLivefeedTasksAllowed()
	)
	{
		return;
	}

	if (!$forAllAccess)
	{
		CUserCounter::IncrementWithSelect(
			CSocNetLogCounter::GetSubSelect2(
				$entityId,
				[
					"TYPE" => $type,
					"FOR_ALL_ACCESS" => false,
					"MULTIPLE" => "Y",
					"SET_TIMESTAMP" => "Y",
					"SEND_TO_AUTHOR" => ($sendToAuthor ? 'Y' : 'N')
				]
			),
			false,
			[
				'SET_TIMESTAMP' => 'Y',
			]
		);
	}
	else // for all, mysql only
	{
		$tag = time();

		// don't send to pull for all records
		CUserCounter::IncrementWithSelect(
			CSocNetLogCounter::GetSubSelect2(
				$entityId,
				[
					"TYPE" => $type,
					"FOR_ALL_ACCESS_ONLY" => true,
					"TAG_SET" => $tag,
					"MULTIPLE" => "Y",
					"SET_TIMESTAMP" => "Y",
					"SEND_TO_AUTHOR" => ($sendToAuthor ? 'Y' : 'N')
				]
			),
			false,
			[
				"SET_TIMESTAMP" => "Y",
				"TAG_SET" => $tag,
			]
		);

		// send to pull discreet records (not for all)
		CUserCounter::IncrementWithSelect(
			CSocNetLogCounter::GetSubSelect2(
				$entityId,
				[
					"TYPE" => $type,
					"FOR_ALL_ACCESS_ONLY" => false,
					"MULTIPLE" => "Y",
					"SET_TIMESTAMP" => "Y",
					"SEND_TO_AUTHOR" => ($sendToAuthor ? 'Y' : 'N')
				]
			),
			true,
			[
				"SET_TIMESTAMP" => "Y",
				"TAG_CHECK" => $tag,
			]
		);
	}

	if ($eventId === "blog_post_important")
	{
		CUserCounter::IncrementWithSelect(
			CSocNetLogCounter::GetSubSelect2(
				$entityId,
				[
					"TYPE" => CSocNetLogCounter::TYPE_LOG_ENTRY,
					"CODE" => "'BLOG_POST_IMPORTANT'",
					"FOR_ALL_ACCESS" => $forAllAccess,
					"MULTIPLE" => "N",
					"SEND_TO_AUTHOR" => ($sendToAuthor ? 'Y' : 'N')
				]
			)
		);
	}

	if ($type === CSocNetLogCounter::TYPE_LOG_COMMENT)
	{
		BitrixSocialnetworkItemLogSubscribe::sendPush(array(
			'commentId' => $entityId
		));
	}
}