- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/classes/general/points.php
- Класс: CAllForumPoints
- Вызов: CAllForumPoints::GetList
static function GetList($arOrder = array("MIN_POINTS"=>"ASC"), $arFilter = array())
{
global $DB;
$arSqlSearch = Array();
$strSqlSearch = "";
$arSqlOrder = Array();
$strSqlOrder = "";
$arFilter = (is_array($arFilter) ? $arFilter : array());
foreach ($arFilter as $key => $val)
{
$key_res = CForumNew::GetFilterOperation($key);
$key = mb_strtoupper($key_res["FIELD"]);
$strNegative = $key_res["NEGATIVE"];
$strOperation = $key_res["OPERATION"];
switch ($key)
{
case "ID":
case "MIN_POINTS":
if (intval($val)<=0)
$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FR.".$key." IS NULL OR FR.".$key."<=0)";
else
$arSqlSearch[] = ($strNegative=="Y"?" FR.".$key." IS NULL OR NOT ":"")."(FR.".$key." ".$strOperation." ".intval($val)." )";
break;
case "CODE":
if ($val == '')
$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FR.CODE IS NULL)";
else
$arSqlSearch[] = ($strNegative=="Y"?" FR.CODE IS NULL OR NOT ":"")."(FR.CODE ".$strOperation." '".$DB->ForSql($val)."' )";
break;
}
}
if (!empty($arSqlSearch))
$strSqlSearch = "WHERE (".implode(") AND (", $arSqlSearch).")";
foreach ($arOrder as $by=>$order)
{
$by = mb_strtoupper($by);
$order = mb_strtoupper($order);
if ($order!="ASC") $order = "DESC";
if ($by == "ID") $arSqlOrder[] = " FR.ID ".$order." ";
elseif ($by == "CODE") $arSqlOrder[] = " FR.CODE ".$order." ";
elseif ($by == "VOTES") $arSqlOrder[] = " FR.VOTES ".$order." ";
else
{
$arSqlOrder[] = " FR.MIN_POINTS ".$order." ";
$by = "MIN_POINTS";
}
}
DelDuplicateSort($arSqlOrder);
if (!empty($arSqlOrder))
$strSqlOrder = " ORDER BY ".implode(", ", $arSqlOrder);
$strSql =
"SELECT FR.ID, FR.MIN_POINTS, FR.CODE, FR.VOTES ".
"FROM b_forum_points FR ".
$strSqlSearch.
$strSqlOrder;
//echo htmlspecialcharsbx($strSql);
return $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__);
}