• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::canAddComment
static function canAddComment($logEntry = array(), $commentEvent = array())
{
	$canAddComments = false;

	global $USER;

	if (
		!is_array($logEntry)
		&& (int)$logEntry > 0
	)
	{
		$res = CSocNetLog::getList(
			array(),
			array(
				"ID" => (int)$logEntry
			),
			false,
			false,
			array("ID", "ENTITY_TYPE", "ENTITY_ID", "EVENT_ID", "USER_ID")
		);

		if (!($logEntry = $res->fetch()))
		{
			return $canAddComments;
		}
	}

	if (
		!is_array($logEntry)
		|| empty($logEntry)
		|| empty($logEntry["EVENT_ID"])
	)
	{
		return $canAddComments;
	}

	if (
		!is_array($commentEvent)
		|| empty($commentEvent)
	)
	{
		$commentEvent = CSocNetLogTools::findLogCommentEventByLogEventID($logEntry["EVENT_ID"]);
	}

	if (is_array($commentEvent))
	{
		$feature = CSocNetLogTools::findFeatureByEventID($commentEvent["EVENT_ID"]);

		if (
			array_key_exists("OPERATION_ADD", $commentEvent)
			&& $commentEvent["OPERATION_ADD"] === "log_rights"
		)
		{
			$canAddComments = CSocNetLogRights::checkForUser($logEntry["ID"], $USER->getID());
		}
		elseif (
			$feature
			&& array_key_exists("OPERATION_ADD", $commentEvent)
			&& $commentEvent["OPERATION_ADD"] <> ''
		)
		{
			$canAddComments = CSocNetFeaturesPerms::canPerformOperation(
				$USER->getID(),
				$logEntry["ENTITY_TYPE"],
				$logEntry["ENTITY_ID"],
				($feature === "microblog" ? "blog" : $feature),
				$commentEvent["OPERATION_ADD"],
				CSocNetUser::isCurrentUserModuleAdmin()
			);
		}
		else
		{
			$canAddComments = true;
		}
	}

	return $canAddComments;
}