1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Config.php
См. документацию.
1<?php
2
4
5use Bitrix\Call\Call;
10use Bitrix\ImOpenLines\V2\Status\Status;
15
16class Config implements \JsonSerializable
17{
18 use ContextCustomer;
19
20 private const NODE = '#bx-im-external-recent-list';
21 private const RU_REGIONS = ['ru', 'by', 'kz', 'uz'];
22
23 private Context $applicationContext;
24
25 public function __construct(?Context $applicationContext = null)
26 {
27 $this->applicationContext = $applicationContext ?? Context::getCurrent();
28 }
29
30 public function jsonSerialize(): array
31 {
32 return [
33 'node' => self::NODE,
34 'preloadedList' => $this->getPreloadedList(),
35 'activeCalls' => $this->getActiveCalls(),
36 'permissions' => $this->getPermissions(),
37 'marketApps' => $this->getMarketApps(),
38 'currentUser' => $this->getCurrentUser(),
39 'loggerConfig' => $this->getLoggerConfig(),
40 'counters' => $this->getCounters(),
41 'settings' => $this->getSettings(),
42 'promoList' => $this->getPromoList(),
43 'phoneSettings' => $this->getPhoneSettings(),
44 'sessionTime' => $this->getSessionTime(),
45 'featureOptions' => $this->getFeatureOptions(),
46 'sessionStatusMap' => $this->getSessionStatusMap(),
47 'tariffRestrictions' => $this->getTariffRestrictions(),
48 'anchors' => $this->getAnchors(),
49 'copilot' => $this->getCopilotData(),
50 ];
51 }
52
53 public function getDesktopDownloadLink(): string
54 {
55 $region = Application::getInstance()->getLicense()->getRegion();
56
57 return
58 in_array($region, self::RU_REGIONS, true)
59 ? 'https://www.bitrix24.ru/features/desktop.php'
60 : 'https://www.bitrix24.com/apps/desktop.php'
61 ;
62 }
63
64 public function getInternetCheckLink(): string
65 {
66 $region = Application::getInstance()->getLicense()->getRegion();
67
68 return
69 in_array($region, self::RU_REGIONS, true)
70 ? '//www.1c-bitrix.ru/200.ok'
71 : '//www.bitrixsoft.com/200.ok'
72 ;
73 }
74
75 protected function getPreloadedList(): array
76 {
77 return \Bitrix\Im\Recent::getList($this->getContext()->getUserId(), [
78 'SKIP_NOTIFICATION' => 'Y',
79 'SKIP_OPENLINES' => 'Y',
80 'JSON' => 'Y',
81 'GET_ORIGINAL_TEXT' => 'Y',
82 'SHORT_INFO' => 'Y',
83 ]) ?: [];
84 }
85
86 protected function getActiveCalls(): array
87 {
88 if (!Loader::includeModule('call'))
89 {
90 return [];
91 }
92
93 return Call::getActiveCalls();
94 }
95
96 protected function getPermissions(): array
97 {
98 $permissionManager = new \Bitrix\Im\V2\Permission(true);
99
100 return [
101 'byChatType' => $permissionManager->getByChatTypes(),
102 'byUserType' => $permissionManager->getByUserTypes(),
103 'actionGroups' => $permissionManager->getActionGroupDefinitions(),
104 'actionGroupsDefaults' => $permissionManager->getDefaultPermissionForGroupActions()
105 ];
106 }
107
108 protected function getMarketApps(): array
109 {
110 return (new \Bitrix\Im\V2\Marketplace\Application())->toRestFormat();
111 }
112
113 protected function getCurrentUser(): array
114 {
115 $currentUser = \CIMContactList::GetUserData([
116 'ID' => $this->getContext()->getUserId(),
117 'PHONES' => 'Y',
118 'SHOW_ONLINE' => 'N',
119 'EXTRA_FIELDS' => 'Y',
120 'DATE_ATOM' => 'Y'
121 ])['users'][$this->getContext()->getUserId()];
122 $currentUser['isAdmin'] = $this->getContext()->getUser()->isAdmin();
123
124 return $currentUser;
125 }
126
127 protected function getLoggerConfig(): array
128 {
129 return \Bitrix\Im\Settings::getLoggerConfig();
130 }
131
132 protected function getCounters(): array
133 {
134 return (new \Bitrix\Im\V2\Message\CounterService($this->getContext()->getUserId()))->get();
135 }
136
137 protected function getSettings(): array
138 {
139 $settings = (new \Bitrix\Im\V2\Settings\UserConfiguration($this->getContext()->getUserId()))->getGeneralSettings();
140 $settings['notifications'] = (new \Bitrix\Im\V2\Settings\UserConfiguration($this->getContext()->getUserId()))->getNotifySettings();
141
142 return $settings;
143 }
144
145 protected function getPromoList(): array
146 {
147 $promoService = ServiceLocator::getInstance()->get('Im.Services.Promotion');
148 $promoType = $this->applicationContext->isDesktop() ? DeviceType::DESKTOP : DeviceType::BROWSER;
149
150 return $promoService->getActive($promoType)->toRestFormat();
151 }
152
153 protected function getPhoneSettings(): array
154 {
155 return \CIMMessenger::getPhoneSettings();
156 }
157
158 protected function getSessionTime(): int
159 {
160 return (new \Bitrix\Im\V2\UpdateState())->getInterval() ?? 0;
161 }
162
163 protected function getFeatureOptions(): Features
164 {
165 return Features::get();
166 }
167
168 protected function getSessionStatusMap(): array
169 {
170 if (!\Bitrix\Main\Loader::includeModule('imopenlines'))
171 {
172 return [];
173 }
174
175 return Status::getMap();
176 }
177
178 protected function getTariffRestrictions(): array
179 {
180 return Limit::getInstance()->getRestrictions();
181 }
182
183 protected function getAnchors(): array
184 {
185 $anchorProvider = AnchorContainer::getInstance()
186 ->getAnchorProvider()
187 ->setContext($this->getContext());
188
189 return $anchorProvider->getUserAnchors();
190 }
191
192 protected function getCopilotData(): array
193 {
194 return [
195 'availableEngines' => (new EngineManager())->getAvailableEnginesForRest(),
196 ];
197 }
198}
Определения limit.php:5
getPreloadedList()
Определения Config.php:75
getDesktopDownloadLink()
Определения Config.php:53
getInternetCheckLink()
Определения Config.php:64
getFeatureOptions()
Определения Config.php:163
getSessionStatusMap()
Определения Config.php:168
__construct(?Context $applicationContext=null)
Определения Config.php:25
getTariffRestrictions()
Определения Config.php:178
static getCurrent()
Определения Context.php:20
static get()
Определения Features.php:54
static getInstance()
Определения servicelocator.php:33
Определения loader.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$region
Определения .description.php:13
Определения Uuid.php:3
trait ContextCustomer
Определения ContextCustomer.php:12
Определения ActionUuid.php:3
$settings
Определения product_settings.php:43