• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/classes/general/user.php
  • Класс: CAllForumUser
  • Вызов: CAllForumUser::CountUsers
static function CountUsers($bActive = False, $arFilter = array())
{
	global $DB;
	$arFilter = (is_array($arFilter) ? $arFilter : array());
	$arSqlSearch = array();
	$strSqlSearch = "";
	if ($bActive)
		$arSqlSearch[] = "NUM_POSTS > 0";
	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 "ACTIVE":
				if ($val == '')
					$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(U.".$key." IS NULL OR ".($DB->type == "MSSQL" ? "LEN" : "LENGTH")."(U.".$key.")<=0)";
				else
					$arSqlSearch[] = ($strNegative=="Y"?" U.".$key." IS NULL OR NOT (":"")."U.".$key." ".$strOperation." '".$DB->ForSql($val)."'".
						($strNegative=="Y"?")":"");
				break;
		}
	}
	if (count($arSqlSearch) > 0)
		$strSqlSearch = " WHERE (".implode(") AND (", $arSqlSearch).") ";

	$strSql = "SELECT COUNT(FU.ID) AS CNT FROM b_forum_user FU INNER JOIN b_user U ON (U.ID = FU.USER_ID)".$strSqlSearch;
	$db_res = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__); if ($ar_res = $db_res->Fetch()) return $ar_res["CNT"]; return 0; }