1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ExternalChatRelations.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Relation;
4
5use Bitrix\Im\V2\Chat\ExternalChat;
6use Bitrix\Im\V2\Chat\ExternalChat\Event\FilterUsersByAccessEvent;
7
9{
10 protected const NEED_ADDITIONAL_FILTER_BY_ACCESS = true;
11
12 public function filterUserIdsByAccess(array $userIds): array
13 {
14 $chat = ExternalChat::getInstance($this->chatId);
15 if (!$chat instanceof ExternalChat)
16 {
17 return $userIds;
18 }
19
20 $event = new FilterUsersByAccessEvent($chat, $userIds);
21 $event->send();
22 if (!$event->hasResult())
23 {
24 return $userIds;
25 }
26
27 $result = $event->getResult();
28 $usersWithAccess = $result->getResult()['userIds'] ?? [];
29 self::deleteUsersWithoutAccess($this->chatId, $userIds, $usersWithAccess);
30
31 return $usersWithAccess;
32 }
33
34 private static function deleteUsersWithoutAccess(int $chatId, array $userIds, array $usersWithAccess): void
35 {
36 $cleaner = LazyCleaner::getInstance();
37 if (!$cleaner->canMarkForDeletion())
38 {
39 return;
40 }
41
42 $toDelete = array_diff($userIds, $usersWithAccess);
43
44 foreach ($toDelete as $userId)
45 {
46 $canMark = LazyCleaner::getInstance()->markForDeletion($chatId, $userId);
47 if (!$canMark)
48 {
49 break;
50 }
51 }
52 }
53}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance()
Определения LazyCleaner.php:22
</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
$event
Определения prolog_after.php:141