1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RecentSync.php
См. документацию.
1<?php
2
4
9
10class RecentSync extends Recent
11{
12 public static function getRecentSync(array $chatIds): self
13 {
14 $recent = new static();
15
16 if (empty($chatIds))
17 {
18 return $recent;
19 }
20
21 $userId = $recent->getContext()->getUserId();
22 $recentEntities = static::getEntities($userId, $chatIds);
23
24 foreach ($recentEntities as $entity)
25 {
26 $recentItem = new RecentSyncItem();
27 $recentItem
28 ->setMessageId((int)$entity['ITEM_MID'])
29 ->setChatId((int)$entity['ITEM_CID'])
30 ->setDialogId(self::getDialogId((int)$entity['ITEM_ID'], $entity['ITEM_TYPE']))
31 ->setUnread(($entity['UNREAD'] ?? 'N') === 'Y')
32 ->setPinned(($entity['PINNED'] ?? 'N') === 'Y')
33 ->setDateUpdate($entity['DATE_UPDATE'] ?? null)
34 ->setDateLastActivity($entity['DATE_LAST_ACTIVITY'] ?? null)
35 ->setMarkedId($entity['MARKED_ID'] ?? 0)
36 ;
37 $recent[] = $recentItem;
38 }
39
40 return $recent;
41 }
42
43 protected static function getEntities(int $userId, array $chatIds): array
44 {
45 $query = RecentTable::query()
46 ->setSelect([
47 'ITEM_TYPE',
48 'ITEM_ID',
49 'ITEM_CID',
50 'ITEM_MID',
51 'UNREAD',
52 'PINNED',
53 'DATE_LAST_ACTIVITY',
54 'DATE_UPDATE',
55 'MARKED_ID',
56 ])
57 ->where('USER_ID', $userId)
58 ->whereIn('ITEM_CID', $chatIds)
59 ;
60
61 return $query->fetchAll();
62 }
63
64 public function getEntityIds(): array
65 {
66 $chatIds = [];
67 $messageIds = [];
68 $dialogIds = [];
69
70 foreach ($this as $entity)
71 {
72 $chatIds[$entity->getChatId()] = $entity->getChatId();
73 $dialogIds[$entity->getChatId()] = $entity->getDialogId();
74 $messageIds[$entity->getMessageId()] = $entity->getMessageId();
75 }
76
77 return [
78 'chatIds' => $chatIds,
79 'messageIds' => $messageIds,
80 'dialogIds' => $dialogIds,
81 ];
82 }
83
84 protected static function getDialogId(int $itemId, string $itemType): string
85 {
86 if ($itemType === Chat::IM_TYPE_PRIVATE)
87 {
88 return (string)$itemId;
89 }
90
91 return 'chat' . $itemId;
92 }
93
94 public function getPopupData(array $excludedList = []): PopupData
95 {
96 return new PopupData([], $excludedList);
97 }
98}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getEntities(int $userId, array $chatIds)
Определения RecentSync.php:43
getPopupData(array $excludedList=[])
Определения RecentSync.php:94
static getDialogId(int $itemId, string $itemType)
Определения RecentSync.php:84
static getRecentSync(array $chatIds)
Определения RecentSync.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
$query
Определения get_search.php:11
$entity