1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
OpenChannelChat.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Chat;
4
5use Bitrix\Im\V2\Entity\User\User;
6use Bitrix\Im\V2\Relation\AddUsersConfig;
7use Bitrix\Im\V2\Relation\DeleteUserConfig;
8use Bitrix\Im\V2\Result;
9use Bitrix\Main\Loader;
10use Bitrix\Main\Type\DateTime;
11
13{
14 public const PULL_TAG_SHARED_LIST = 'IM_SHARED_CHANNEL_LIST';
15
17 {
18 return ['openChannel'];
19 }
20
21 protected function sendMessageUsersAdd(array $usersToAdd, AddUsersConfig $config): void
22 {
23 parent::sendMessageUsersAdd($this->getExtranetUsersToAdd($usersToAdd), $config);
24 }
25
26 protected function getExtranetUsersToAdd(array $usersToAdd): array
27 {
28 if (!$this->getExtranet())
29 {
30 return [];
31 }
32
33 $extranetUsersToAdd = [];
34 foreach ($usersToAdd as $userId)
35 {
36 if (User::getInstance($userId)->isExtranet())
37 {
38 $extranetUsersToAdd[$userId] = $userId;
39 }
40 }
41
42 return $extranetUsersToAdd;
43 }
44
46 {
47 return;
48 }
49
50 public function extendPullWatch(): void
51 {
52 if (!Loader::includeModule('pull'))
53 {
54 return;
55 }
56
57 parent::extendPullWatch();
58
59 if ($this->getSelfRelation() === null)
60 {
61 \CPullWatch::Add($this->getContext()->getUserId(), "IM_PUBLIC_{$this->getId()}", true);
62 }
63 }
64
65 protected function getAccessCodesForDiskFolder(): array
66 {
67 $accessCodes = parent::getAccessCodesForDiskFolder();
68 $departmentCode = \CIMDisk::GetTopDepartmentCode();
69
70 if ($departmentCode)
71 {
72 $driver = \Bitrix\Disk\Driver::getInstance();
73 $rightsManager = $driver->getRightsManager();
74 $accessCodes[] = [
75 'ACCESS_CODE' => $departmentCode,
76 'TASK_ID' => $rightsManager->getTaskIdByName($rightsManager::TASK_READ)
77 ];
78 }
79
80 return $accessCodes;
81 }
82
83 protected function updateStateAfterRelationsAdd(array $usersToAdd): self
84 {
85 parent::updateStateAfterRelationsAdd($usersToAdd);
86
87 if (Loader::includeModule('pull'))
88 {
89 foreach ($usersToAdd as $userId)
90 {
91 \CPullWatch::Delete($userId, 'IM_PUBLIC_' . $this->getId());
92 }
93 }
94
95 return $this;
96 }
97
98 public function filterUsersToMention(array $userIds): array
99 {
100 $result = [];
101 $relations = $this->getRelationsByUserIds($userIds);
102
103 foreach ($userIds as $userId)
104 {
105 $relation = $relations->getByUserId($userId, $this->getChatId());
106 if (
107 ($relation === null
108 || $relation->getNotifyBlock())
110 )
111 {
113 }
114 }
115
116 return $result;
117 }
118
119 public function needToSendPublicPull(): bool
120 {
121 return true;
122 }
123
124 public static function sendSharedPull(array $pull): bool
125 {
126 $pull['extra']['is_shared_event'] = true;
127
128 return \CPullWatch::AddToStack(\Bitrix\Im\V2\Chat\OpenChannelChat::PULL_TAG_SHARED_LIST, $pull);
129 }
130
131 public function isNew(): bool
132 {
133 $lastDay = (new DateTime())->add('-1 day');
134 $dateCreate = $this->getDateCreate();
135
136 if (!$dateCreate instanceof DateTime)
137 {
138 return false;
139 }
140
141 return $dateCreate->getTimestamp() > $lastDay->getTimestamp();
142 }
143
144 protected function getDefaultType(): string
145 {
146 return self::IM_TYPE_OPEN_CHANNEL;
147 }
148
149 protected function checkAccessInternal(int $userId): Result
150 {
151 $checkResult = parent::checkAccessInternal($userId);
152
153 if ($checkResult->isSuccess())
154 {
155 return $checkResult;
156 }
157
158 $result = new Result();
159
160 if (User::getInstance($userId)->isExtranet())
161 {
163 }
164
165 return $result;
166 }
167
168 public static function extendPullWatchToCommonList(?int $userId = null): void
169 {
170 $userId ??= User::getCurrent()->getId();
171
172 if (Loader::includeModule('pull'))
173 {
174 \CPullWatch::Add($userId, static::PULL_TAG_SHARED_LIST, true);
175 }
176 }
177}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
const ACCESS_DENIED
Определения ChatError.php:19
add(array $params, ?Context $context=null)
Определения GroupChat.php:99
checkAccessInternal(int $userId)
Определения OpenChannelChat.php:149
sendMessageUsersAdd(array $usersToAdd, AddUsersConfig $config)
Определения OpenChannelChat.php:21
updateStateAfterRelationsAdd(array $usersToAdd)
Определения OpenChannelChat.php:83
getExtranetUsersToAdd(array $usersToAdd)
Определения OpenChannelChat.php:26
static extendPullWatchToCommonList(?int $userId=null)
Определения OpenChannelChat.php:168
static sendSharedPull(array $pull)
Определения OpenChannelChat.php:124
sendMessageUserDelete(int $userId, DeleteUserConfig $config)
Определения OpenChannelChat.php:45
filterUsersToMention(array $userIds)
Определения OpenChannelChat.php:98
static getCurrent()
Определения User.php:89
static getInstance()
Определения application.php:98
Определения result.php:20
static GetTopDepartmentCode()
Определения im_disk.php:2502
static GetNotifyAccess($userId, $moduleId, $eventId, $clientId)
Определения im_settings.php:255
const CLIENT_SITE
Определения im_settings.php:15
</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
Определения ActionUuid.php:3
$config
Определения quickway.php:69