1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CounterServiceAgent.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
15use CAgent;
16
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]);
117 CounterOverflowService::deleteAllByUserId($userId);
118
119 if (count($ids) < $limit)
120 {
121 return '';
122 }
123
124 return self::formatDeleteAllAgentName($userId, $withNotify, $lastUnreadId);
125 }
126}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static deleteAll(int $userId, bool $withNotify, int $lastUnreadId)
Определения CounterServiceAgent.php:93
static deleteAllViaAgent(int $userId, bool $withNotify)
Определения CounterServiceAgent.php:72
static clearCache($moduleId)
Определения option.php:464
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$filter
Определения iblock_catalog_list.php:54
const IM_MESSAGE_SYSTEM
Определения include.php:21
</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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799