Exemplo n.º 1
0
    } else {
        $arFilter = array();
        if (!CForumUser::IsAdmin()) {
            $arFilter = array("LID" => SITE_ID, "PERMS" => array($USER->GetGroups(), 'A'), "ACTIVE" => "Y");
        } elseif ($arParams["SHOW_FORUM_ANOTHER_SITE"] == "Y") {
            $arFilter["LID"] = SITE_ID;
        }
        if (is_array($arParams["FORUM_ID"]) && !empty($arParams["FORUM_ID"])) {
            $arFilter["@ID"] = $arParams["FORUM_ID"];
        }
        if (!empty($arParams["FID"])) {
            $arFilter["ID"] = $arParams["FID"];
        } else {
            $arResult["STATISTIC"]["USERS"] = CUser::GetCount();
            $arResult["STATISTIC"]["USERS_ON_FORUM"] = CForumUser::CountUsers(false, array("ACTIVE" => "Y"));
            $arResult["STATISTIC"]["USERS_ON_FORUM_ACTIVE"] = CForumUser::CountUsers(true, array("ACTIVE" => "Y"));
        }
        $db_res = CForumNew::GetListEx(array(), $arFilter);
        if ($db_res && ($res = $db_res->GetNext())) {
            do {
                $arResult["STATISTIC"]["FORUMS"]++;
                $arResult["STATISTIC"]["TOPICS"] += intVal($res["TOPICS"]);
                $arResult["STATISTIC"]["POSTS"] += intVal($res["POSTS"]);
            } while ($res = $db_res->GetNext());
        }
        if ($arParams["CACHE_TIME_FOR_FORUM_STAT"] > 0) {
            $cache->StartDataCache($arParams["CACHE_TIME_FOR_FORUM_STAT"], $cache_id, $cache_path);
            $cache->EndDataCache(array("STATISTIC" => $arResult["STATISTIC"]));
        }
    }
}