• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/user_counter.php
  • Класс: CAllUserCounter
  • Вызов: CAllUserCounter::ClearByTag
static function ClearByTag($tag, $code, $site_id = SITE_ID, $sendPull = true)
{
	global $DB, $CACHE_MANAGER;

	if ($tag == '' || $code == '')
	{
		return false;
	}

	$strSQL = "
		UPDATE b_user_counter SET
		CNT = 0
		WHERE TAG = '" . $DB->ForSQL($tag) . "' AND CODE = '" . $DB->ForSQL($code) . "'
		AND (SITE_ID = '" . $site_id . "' OR SITE_ID = '" . self::ALL_SITES . "')";
	$DB->Query($strSQL, false, "File: ".__FILE__."
Line: ".__LINE__); self::$counters = []; $CACHE_MANAGER->CleanDir("user_counter"); if ($sendPull && self::CheckLiveMode()) { global $DB; $arSites = Array(); $by = ''; $order = ''; $res = CSite::GetList($by, $order, Array("ACTIVE" => "Y")); while ($row = $res->Fetch()) { $arSites[] = $row['ID']; } $helper = BitrixMainApplication::getConnection()->getSqlHelper(); $strSQL = " SELECT uc.USER_ID as CHANNEL_ID, 'private' as CHANNEL_TYPE, 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 TAG = '".$DB->ForSQL($tag)."' AND CODE = '".$DB->ForSQL($code)."' AND (SITE_ID = '".$site_id."' OR SITE_ID = '" . self::ALL_SITES . "')"; $res = $DB->Query($strSQL, false, "FILE: ".__FILE__."
LINE: ".__LINE__); $pullMessage = []; while ($row = $res->Fetch()) { if (!( $row['CHANNEL_TYPE'] === 'private' || ( $row['CHANNEL_TYPE'] === 'shared' && (int)$row['USER_ID'] === 0 ) )) { continue; } if ($row['SITE_ID'] === self::ALL_SITES) { foreach ($arSites as $siteId) { if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']])) { $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += (int)$row['CNT']; } else { $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = (int)$row['CNT']; } } } elseif (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']])) { $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += (int)$row['CNT']; } else { $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = (int)$row['CNT']; } } foreach ($pullMessage as $channelId => $arMessage) { BitrixPullEvent::add($channelId, Array( 'module_id' => 'main', 'command' => 'user_counter', 'expiry' => 3600, 'params' => $arMessage, )); } } return true; }