1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Recent.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Recent;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Common\ContextCustomer;
7use Bitrix\Im\V2\Entity\User\UserPopupItem;
8use Bitrix\Im\V2\Message;
9use Bitrix\Im\V2\Message\MessagePopupItem;
10use Bitrix\Im\V2\MessageCollection;
11use Bitrix\Im\V2\Registry;
12use Bitrix\Im\V2\Rest\PopupData;
13use Bitrix\Im\V2\Rest\PopupDataAggregatable;
14use Bitrix\Im\V2\Rest\PopupDataItem;
15use Bitrix\Im\V2\Settings\UserConfiguration;
16
21{
22 use ContextCustomer;
23
24 public function getPopupData(array $excludedList = []): PopupData
25 {
26 $messageIds = [];
27 $chats = [];
28 $chatIds = [];
29 $userIds = [];
30
31 foreach ($this as $item)
32 {
33 $messageIds[] = $item->getMessageId();
34 $chats[] = Chat::getInstance($item->getChatId());
35 $chatIds[] = $item->getChatId();
36
37 if ($item->getType() === RecentType::User)
38 {
39 $userIds[] = $item->getId();
40 }
41 }
42
43 $messages = $this->getMessagesForPopupData($messageIds);
44
45 return new PopupData([
47 new Chat\ChatPopupItem($chats),
50 new UserPopupItem($userIds),
51 Chat\Copilot\CopilotPopupItem::getInstanceByChatIdsAndMessages($messages, $chatIds),
52 ], $excludedList);
53 }
54
55 final public static function getRestEntityName(): string
56 {
57 return 'recentItems';
58 }
59
60 public function toRestFormat(array $option = []): array
61 {
62 $rest = [];
63
64 foreach ($this as $item)
65 {
66 $rest[] = $item->toRestFormat();
67 }
68
69 return $rest;
70 }
71
72 public function merge(PopupDataItem $item): PopupDataItem
73 {
74 return $this;
75 }
76
77 protected static function getOrder(int $userId): array
78 {
79 $userSettings = (new UserConfiguration($userId))->getGeneralSettings();
80
81 if (isset($userSettings['pinnedChatSort']) && $userSettings['pinnedChatSort'] === 'byCost')
82 {
83 return [
84 'PINNED' => 'DESC',
85 'PIN_SORT' => 'ASC',
86 'DATE_LAST_ACTIVITY' => 'DESC',
87 ];
88 }
89
90 return [
91 'PINNED' => 'DESC',
92 'DATE_LAST_ACTIVITY' => 'DESC',
93 ];
94 }
95
96 protected function getMessagesForPopupData(array $messageIds): MessageCollection
97 {
98 return
99 (new MessageCollection($messageIds))
100 ->fillParams()
101 ;
102 }
103}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstanceMessages(MessageCollection $messages, bool $shortInfo=false)
Определения MessagePopupItem.php:27
static getRestEntityName()
Определения Recent.php:55
toRestFormat(array $option=[])
Определения Recent.php:60
static getOrder(int $userId)
Определения Recent.php:77
getPopupData(array $excludedList=[])
Определения Recent.php:24
getMessagesForPopupData(array $messageIds)
Определения Recent.php:96
merge(PopupDataItem $item)
Определения Recent.php:72
static getInstance()
Определения application.php:98
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$messages
Определения template.php:8
$option
Определения options.php:1711