1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
CounterServiceAgent.php
См. документацию.
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
Bitrix\Im\V2\Message\CounterService
;
6
7
use
Bitrix\Im\Model\MessageUnreadTable
;
8
use
Bitrix\Im\V2\Message\Counter\CounterOverflowService
;
9
use
Bitrix\Im\V2\Message\CounterService
;
10
use
Bitrix\Main\ArgumentException
;
11
use
Bitrix\Main\Config\Option
;
12
use
Bitrix\Main\ObjectPropertyException
;
13
use
Bitrix\Main\ORM\Fields\ExpressionField
;
14
use
Bitrix\Main\SystemException
;
15
use CAgent;
16
17
final
class
CounterServiceAgent
18
{
19
private
const
UNREAD_DELETE_ALL_LIMIT = 100000;
20
private
const
UNREAD_DELETE_ALL_INTERVAL = 10;
21
27
private
static
function
getLastUnreadId(
int
$userId
,
bool
$withNotify):
int
28
{
29
$result
= MessageUnreadTable::getList([
30
'select'
=> [
'ID'
],
31
'filter'
=> self::buildDeleteAllFilter(
$userId
, $withNotify),
32
'order'
=> [
'ID'
=>
'DESC'
],
33
'limit'
=> 1,
34
]);
35
36
if
(is_array($row =
$result
->fetch()))
37
{
38
return
(
int
)$row[
'ID'
];
39
}
40
41
return
0;
42
}
43
44
private
static
function
buildDeleteAllFilter(
int
$userId
,
bool
$withNotify):
array
45
{
46
$filter
= [
'=USER_ID'
=>
$userId
];
47
48
if
(!$withNotify)
49
{
50
$filter
[
'!=CHAT_TYPE'
] = \
IM_MESSAGE_SYSTEM
;
51
}
52
53
return
$filter
;
54
}
55
56
private
static
function
formatDeleteAllAgentName(
int
$userId
,
bool
$withNotify,
int
$lastUnreadId):
string
57
{
58
$params
= [
59
$userId
,
60
$withNotify ?
'true'
:
'false'
,
61
$lastUnreadId,
62
];
63
64
return
__CLASS__ .
'::deleteAll('
. implode(
', '
,
$params
) .
');'
;
65
}
66
72
public
static
function
deleteAllViaAgent
(
int
$userId
,
bool
$withNotify): void
73
{
74
$lastUnreadId = self::getLastUnreadId(
$userId
, $withNotify);
75
$agentName =
self::deleteAll
(
$userId
,$withNotify, $lastUnreadId);
76
77
if
($agentName !==
''
)
78
{
79
CAgent::addAgent(
80
$agentName,
81
'im'
,
82
'N'
,
83
self::UNREAD_DELETE_ALL_INTERVAL,
84
);
85
}
86
}
87
93
public
static
function
deleteAll
(
int
$userId
,
bool
$withNotify,
int
$lastUnreadId): string
94
{
95
$filter
= self::buildDeleteAllFilter(
$userId
, $withNotify);
96
$limit = (int)Option::get(
'im'
,
'unread_delete_all_limit'
, self::UNREAD_DELETE_ALL_LIMIT);
97
$result
= MessageUnreadTable::getList([
98
'select'
=> [
'ID'
],
99
'filter'
=>
$filter
,
100
'limit'
=> $limit,
101
]);
102
103
$ids = [];
104
105
foreach
($r =
$result
->fetchAll() as $row)
106
{
107
$ids[] = (int)$row[
'ID'
];
108
}
109
110
if
(empty($ids))
111
{
112
return
''
;
113
}
114
115
MessageUnreadTable::deleteByFilter([
'@ID'
=> $ids]);
116
CounterService::clearCache
(
$userId
);
117
CounterOverflowService::deleteAllByUserId(
$userId
);
118
119
if
(
count
($ids) < $limit)
120
{
121
return
''
;
122
}
123
124
return
self::formatDeleteAllAgentName(
$userId
, $withNotify, $lastUnreadId);
125
}
126
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Im\Model\MessageUnreadTable
Определения
messageunread.php:51
Bitrix\Im\V2\Message\Counter\CounterOverflowService
Определения
CounterOverflowService.php:9
Bitrix\Im\V2\Message\CounterService\CounterServiceAgent
Определения
CounterServiceAgent.php:18
Bitrix\Im\V2\Message\CounterService\CounterServiceAgent\deleteAll
static deleteAll(int $userId, bool $withNotify, int $lastUnreadId)
Определения
CounterServiceAgent.php:93
Bitrix\Im\V2\Message\CounterService\CounterServiceAgent\deleteAllViaAgent
static deleteAllViaAgent(int $userId, bool $withNotify)
Определения
CounterServiceAgent.php:72
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
Bitrix\Main\Config\Option
Определения
option.php:15
Bitrix\Main\Config\Option\clearCache
static clearCache($moduleId)
Определения
option.php:464
Bitrix\Main\ORM\Fields\ExpressionField
Определения
expressionfield.php:25
Bitrix\Main\ObjectPropertyException
Определения
ObjectPropertyException.php:9
Bitrix\Main\SystemException
Определения
SystemException.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$filter
$filter
Определения
iblock_catalog_list.php:54
IM_MESSAGE_SYSTEM
const IM_MESSAGE_SYSTEM
Определения
include.php:21
Bitrix\Im\V2\Message\CounterService
Определения
CounterServiceAgent.php:5
count
</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
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
im
lib
V2
Message
CounterService
CounterServiceAgent.php
Создано системой
1.14.0