- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/ratings.php
- Класс: CAllRatings
- Вызов: CAllRatings::GetRatingUserProp
static function GetRatingUserProp($ratingId, $entityId)
{
global $DB;
$err_mess = (CRatings::err_mess())."
Function: GetRatingUserProp
Line: ";
$ratingId = (int)$ratingId;
static $cache = array();
if(!array_key_exists($ratingId, $cache))
$cache[$ratingId] = array();
$arResult = array();
$arToSelect = array();
if(is_array($entityId))
{
foreach($entityId as $value)
{
$value = (int)$value;
if($value > 0)
{
if(array_key_exists($value, $cache[$ratingId]))
$arResult[$value] = $cache[$ratingId][$value];
else
{
$arResult[$value] = $cache[$ratingId][$value] = array();
$arToSelect[$value] = $value;
}
}
}
}
else
{
$value = (int)$entityId;
if($value > 0)
{
if(isset($cache[$ratingId][$value]))
$arResult[$value] = $cache[$ratingId][$value];
else
{
$arResult[$value] = $cache[$ratingId][$value] = array();
$arToSelect[$value] = $value;
}
}
}
if(!empty($arToSelect))
{
$strSql = "
SELECT RATING_ID, ENTITY_ID, BONUS, VOTE_WEIGHT, VOTE_COUNT
FROM b_rating_user
WHERE RATING_ID = '".$ratingId."' AND ENTITY_ID IN (".implode(',', $arToSelect).")
";
$res = $DB->Query($strSql, false, $err_mess.__LINE__);
while($arRes = $res->Fetch())
$arResult[$arRes["ENTITY_ID"]] = $cache[$ratingId][$arRes["ENTITY_ID"]] = $arRes;
}
if(!is_array($entityId) && !empty($arResult))
$arResult = array_pop($arResult);
return $arResult;
}