• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/ratings.php
  • Класс: CAllRatings
  • Вызов: CAllRatings::Calculate
static function Calculate($ID, $bForceRecalc = false)
{
	global $DB;

	$ID = (int)$ID;
	$err_mess = (CRatings::err_mess())."
Function: Calculate
Line: "; $strSql = "SELECT RC.*, ".$DB->DateToCharFunction("RC.LAST_MODIFIED")." LAST_MODIFIED, ".$DB->DateToCharFunction("RC.LAST_CALCULATED")." LAST_CALCULATED, ".$DB->DateToCharFunction("RC.NEXT_CALCULATION")." NEXT_CALCULATION FROM b_rating_component RC WHERE RATING_ID = $ID and ACTIVE = 'Y' ".($bForceRecalc ? '' : 'AND NEXT_CALCULATION <= '.$DB->GetNowFunction()); $res = $DB->Query($strSql, false, $err_mess.__LINE__); while($arRes = $res->Fetch()) { if(CModule::IncludeModule(mb_strtolower($arRes['MODULE_ID']))) { $arRes['CONFIG'] = unserialize($arRes['CONFIG'], ['allowed_classes' => false]); // If the type is automatic calculation of parameters * global vote weight $sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto"); if ($sRatingWeightType === 'auto') { $voteWeight = COption::GetOptionString("main", "rating_vote_weight", 1); $arRes['CONFIG']['COEFFICIENT'] = ($arRes['CONFIG']['COEFFICIENT'] ?? 1) * $voteWeight; } if ($arRes['EXCEPTION_METHOD'] <> '') { if (method_exists($arRes['CLASS'], $arRes['EXCEPTION_METHOD'])) { $exceptionText = call_user_func(array($arRes['CLASS'], $arRes['EXCEPTION_METHOD'])); if ($exceptionText === false) { if (method_exists($arRes['CLASS'], $arRes['CALC_METHOD'])) { $result = call_user_func(array($arRes['CLASS'], $arRes['CALC_METHOD']), $arRes); } } } } else { if (method_exists($arRes['CLASS'], $arRes['CALC_METHOD'])) { $result = call_user_func(array($arRes['CLASS'], $arRes['CALC_METHOD']), $arRes); } } } } CRatings::BuildRating($ID); return "CRatings::Calculate($ID);"; }