1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
user_counter_page.php
См. документацию.
1<?php
2
4
6{
7 protected static function setUserIdOption($value = false)
8 {
9 // \Bitrix\Main\Config\Option::set('main', 'user_counter_pull_page_start', $value);
10 }
11
12 protected static function getUserIdOption()
13 {
14 // return \Bitrix\Main\Config\Option::get('main', 'user_counter_pull_page_start', false);
15 }
16
17 public static function getPageSizeOption($defaultValue = 100)
18 {
19 $value = (int)Option::get('main', 'user_counter_pull_page_size', $defaultValue);
20 if ($value <= 0)
21 {
22 $value = $defaultValue;
23 }
24
25 return $value;
26 }
27
28 public static function setNewEvent()
29 {
31 }
32
33 protected static function getMinMax($prevMax = 0)
34 {
35 global $DB;
36
38
39 $strSQL = "
40 SELECT USER_ID
41 FROM b_user_counter uc
42 WHERE SENT = '0' AND USER_ID > " . (int)$prevMax . "
43 GROUP BY USER_ID
44 ORDER BY USER_ID ASC
45 LIMIT ".$pageSize."
46 ";
47
48 $res = $DB->query($strSQL);
49
50 $i = 0;
51 while($row = $res->fetch())
52 {
53 if (!$i)
54 {
55 $minValue = $row["USER_ID"];
56 }
57 else
58 {
59 $maxValue = $row["USER_ID"];
60 }
61 $i++;
62 }
63
64 if ($i)
65 {
66 return [
67 'MIN' => (int)$minValue,
68 'MAX' => (int)$maxValue,
69 ];
70 }
71
72 return false;
73 }
74
75 public static function checkSendCounter()
76 {
77 global $DB, $USER;
78
80
81 if(!$connection->lock('counterpull'))
82 {
83 return;
84 }
85
86 $counterPageSize = (int)static::getPageSizeOption(100);
87
88 $userSQL = "SELECT USER_ID FROM b_user_counter WHERE SENT='0' GROUP BY USER_ID LIMIT ".$counterPageSize;
89 $res = $DB->Query($userSQL);
90
91 $pullMessage = [];
92 $userIdList = [];
93
94 while ($row = $res->fetch())
95 {
96 $userIdList[] = (int)$row["USER_ID"];
97 }
98
99 if (
100 is_object($USER)
101 && $USER->isAuthorized()
102 && count($userIdList) >= $counterPageSize
103 && !in_array((int)$USER->getId(), $userIdList, true)
104 )
105 {
106 $userIdList[] = (int)$USER->getId();
107 }
108
109 $userString = '';
110 foreach($userIdList as $userId)
111 {
112 $userString .= ($userString <> ''? ', ' : '').$userId;
113 }
114
115 if ($userString <> '')
116 {
117 $arSites = array();
118 $by = '';
119 $order = '';
120 $res = CSite::GetList($by, $order, array("ACTIVE" => "Y"));
121 while($row = $res->Fetch())
122 {
123 $arSites[] = $row['ID'];
124 }
125
126 $helper = $connection->getSqlHelper();
127
128 $strSQL = "
129 SELECT uc.USER_ID as CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT
130 FROM b_user_counter uc
131 INNER JOIN b_user u ON u.ID = uc.USER_ID AND (CASE WHEN u.EXTERNAL_AUTH_ID IN ('" . implode("', '", \Bitrix\Main\UserTable::getExternalUserTypes()) . "') THEN 'Y' ELSE 'N' END) = 'N' AND u.LAST_ACTIVITY_DATE > " . $helper->addSecondsToDateTime('(-3600)')."
132 WHERE uc.USER_ID IN (".$userString.") AND uc.CODE NOT LIKE '" . CUserCounter::LIVEFEED_CODE . "L%' AND uc.SENT = '0'
133 ";
134
135 $res = $DB->Query($strSQL);
136 while($row = $res->Fetch())
137 {
138 CUserCounter::addValueToPullMessage($row, $arSites, $pullMessage);
139 }
140
141 $strSQL = "
142 SELECT uc.USER_ID as CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT
143 FROM b_user_counter uc
144 INNER JOIN b_user u ON u.ID = uc.USER_ID AND (CASE WHEN u.EXTERNAL_AUTH_ID IN ('" . implode("', '", \Bitrix\Main\UserTable::getExternalUserTypes()) . "') THEN 'Y' ELSE 'N' END) = 'N' AND u.LAST_ACTIVITY_DATE > " . $helper->addSecondsToDateTime('(-3600)')."
145 WHERE uc.USER_ID IN (" . $userString . ") AND uc.CODE LIKE '" . CUserCounter::LIVEFEED_CODE . "L%'
146 ";
147
148 $res = $DB->Query($strSQL);
149 while($row = $res->Fetch())
150 {
151 CUserCounter::addValueToPullMessage($row, $arSites, $pullMessage);
152 }
153
154 $DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0' AND USER_ID IN (".$userString.")");
155 }
156
157 $connection->unlock('counterpull');
158
159 if (\CUserCounter::CheckLiveMode())
160 {
161 foreach ($pullMessage as $channelId => $arMessage)
162 {
164 'module_id' => 'main',
165 'command' => 'user_counter',
166 'expiry' => 3600,
167 'params' => $arMessage,
168 ));
169 }
170 }
171 }
172}
$connection
Определения actionsdefinitions.php:38
$arSites
Определения options.php:15
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
if(empty( $fields)) foreach($fields as $field) $channelId
Определения push.php:23
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getConnection($name="")
Определения application.php:638
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения event.php:22
static setUserIdOption($value=false)
Определения user_counter_page.php:7
static getMinMax($prevMax=0)
Определения user_counter_page.php:33
static getPageSizeOption($defaultValue=100)
Определения user_counter_page.php:17
static setNewEvent()
Определения user_counter_page.php:28
static checkSendCounter()
Определения user_counter_page.php:75
static getUserIdOption()
Определения user_counter_page.php:12
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$pageSize
Определения csv_new_run.php:34
$order
Определения payment.php:8
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936