- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/mysql/user_counter.php
- Класс: CUserCounter
- Вызов: CUserCounter::sendLiveFeedPull
static function sendLiveFeedPull()
{
global $DB;
$pullMessage = [];
$connection = BitrixMainApplication::getConnection();
$connection->lock('pull');
$sites = [];
$by = '';
$order = '';
$queryObject = CSite::getList($by, $order, ['ACTIVE' => 'Y']);
while ($row = $queryObject->fetch())
{
$sites[] = $row['ID'];
}
$helper = $connection->getSqlHelper();
$strSQL = "
SELECT uc.USER_ID as CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT
FROM b_user_counter uc
INNER JOIN b_user u ON u.ID = uc.USER_ID AND (CASE WHEN u.EXTERNAL_AUTH_ID IN ('"
. implode("', '", BitrixMainUserTable::getExternalUserTypes())
. "') THEN 'Y' ELSE 'N' END) = 'N' AND u.LAST_ACTIVITY_DATE > "
.$helper->addSecondsToDateTime('(-3600)')."
WHERE uc.CODE LIKE '" . self::LIVEFEED_CODE . "%'
";
$queryObject = $DB->Query($strSQL, false, "FILE: ".__FILE__."
LINE: ".__LINE__);
while($row = $queryObject->fetch())
{
self::addValueToPullMessage($row, $sites, $pullMessage);
}
$connection->unlock('pull');
foreach ($pullMessage as $channelId => $arMessage)
{
BitrixPullEvent::add($channelId, [
'module_id' => 'main',
'command' => 'user_counter',
'expiry' => 3600,
'params' => $arMessage,
]);
}
}