• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_follow.php
  • Класс: CSocNetLogFollow
  • Вызов: CSocNetLogFollow::GetExactValueByRating
static function GetExactValueByRating($user_id, $rating_type_id, $rating_entity_id)
{
	global $DB;

	if (
		intval($user_id) <= 0
		|| $rating_type_id == ''
		|| intval($rating_entity_id) <= 0
	)
		return false;

	$arPostTypeID = array(
		"BLOG_POST", 
		"FORUM_TOPIC", 
		"IBLOCK_ELEMENT", 
		"BITRIX24_NEW_USER", 
		"INTRANET_NEW_USER", 
		"LOG_ENTRY"
	);

	$arCommentTypeID = array(
		"BLOG_COMMENT", 
		"FORUM_POST", 
		"BITRIX24_NEW_USER_COMMENT", 
		"INTRANET_NEW_USER_COMMENT",
		"LOG_COMMENT"
	);

	$strRes = false;

	if (
		in_array($rating_type_id, $arCommentTypeID)
		|| 
		(
			!in_array($rating_type_id, $arCommentTypeID)
			&& !in_array($rating_type_id, $arPostTypeID)
		)
	)
	{
		$strSQL = "SELECT TYPE FROM b_sonet_log_follow LFW 
			INNER JOIN b_sonet_log_comment LC ON 
				LC.RATING_TYPE_ID = '".$rating_type_id."' 
				AND LC.RATING_ENTITY_ID = ".intval($rating_entity_id)." 
				AND LFW.REF_ID = LC.LOG_ID 
				AND LFW.CODE = ".$DB->Concat("'L'", ($DB->type == "MSSQL" ? "CAST(LC.LOG_ID as varchar(17))" : "LC.LOG_ID"))." 
			WHERE  
				LFW.USER_ID = ".intval($user_id);

		$dbRes = $DB->Query($strSQL, false, "File: ".__FILE__."
Line: ".__LINE__); if ($arRes = $dbRes->Fetch()) { $strRes = $arRes["TYPE"]; } } if ( in_array($rating_type_id, $arPostTypeID) || ( !in_array($rating_type_id, $arCommentTypeID) && !in_array($rating_type_id, $arPostTypeID) && !$strRes ) ) { $strSQL = "SELECT TYPE FROM b_sonet_log_follow LFW INNER JOIN b_sonet_log L ON L.RATING_TYPE_ID = '".$rating_type_id."' AND L.RATING_ENTITY_ID = ".intval($rating_entity_id)." AND LFW.REF_ID = L.ID AND LFW.CODE = ".$DB->Concat("'L'", ($DB->type == "MSSQL" ? "CAST(L.ID as varchar(17))" : "L.ID"))." WHERE LFW.USER_ID = ".intval($user_id); $dbRes = $DB->Query($strSQL, false, "File: ".__FILE__."
Line: ".__LINE__); if ($arRes = $dbRes->Fetch()) { $strRes = $arRes["TYPE"]; } } return $strRes; }