Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
UserBot.php
1<?php
2
4
6use Bitrix\Imbot\Bot\CopilotChatBot;
8
9class UserBot extends User
10{
11 private ?BotData $botData = null;
12
13 protected function fillOnlineData(bool $withStatus = false): void
14 {
15 return;
16 }
17
18 public function isOnlineDataFilled(bool $withStatus): bool
19 {
20 return true;
21 }
22
23 protected function checkAccessWithoutCaching(User $otherUser): bool
24 {
25 if (!static::$moduleManager::isModuleInstalled('intranet'))
26 {
27 return $this->hasAccessBySocialNetwork($otherUser->getId());
28 }
29
30 if (Loader::includeModule('imbot') && $this->getBotData()->getCode() === CopilotChatBot::BOT_CODE)
31 {
32 return false;
33 }
34
35 global $USER;
36 if ($otherUser->isExtranet())
37 {
38 if ($otherUser->getId() === $USER->GetID())
39 {
40 if ($USER->IsAdmin())
41 {
42 return true;
43 }
44
45 if (static::$loader::includeModule('bitrix24'))
46 {
47 if (\CBitrix24::IsPortalAdmin($otherUser->getId()) || \Bitrix\Bitrix24\Integrator::isIntegrator($otherUser->getId()))
48 {
49 return true;
50 }
51 }
52 }
53
54 $inGroup = \Bitrix\Im\Integration\Socialnetwork\Extranet::isUserInGroup($this->getId(), $otherUser->getId());
55 if ($inGroup)
56 {
57 return true;
58 }
59
60
61 return false;
62 }
63
64 if ($this->isNetwork())
65 {
66 return true;
67 }
68
69 return true;
70 }
71
72 public function toRestFormat(array $option = []): array
73 {
74 $userData = parent::toRestFormat($option);
75
76 if (isset($userData['botData']))
77 {
78 return $userData;
79 }
80
81 $botData = $this->getBotData()->toRestFormat();
82 $userData['botData'] = empty($botData) ? null : $botData;
83
84 return $userData;
85 }
86
87 public function getBotData(): BotData
88 {
89 if ($this->botData !== null)
90 {
91 return $this->botData;
92 }
93
94 return BotData::getInstance($this->getId());
95 }
96}
checkAccessWithoutCaching(User $otherUser)
Definition UserBot.php:23
toRestFormat(array $option=[])
Definition UserBot.php:72
isOnlineDataFilled(bool $withStatus)
Definition UserBot.php:18
fillOnlineData(bool $withStatus=false)
Definition UserBot.php:13
hasAccessBySocialNetwork(int $idOtherUser)
Definition User.php:230