24 private array $parameters = [];
25 private bool $isCloud;
29 $this->currentUser = CurrentUser::get();
30 $this->isCloud = Loader::includeModule(
'bitrix24');
35 $this->buildPortalInformation();
36 $this->buildUserCharacteristics();
37 $this->buildSupportConfiguration();
38 $this->buildKeyConfiguration();
39 $this->buildExternalParameters();
40 $this->buildHeadInformation();
42 return $this->parameters;
45 private function buildSupportConfiguration(): void
47 if (!Loader::includeModule(
'imbot'))
52 $this->parameters += [
53 'support_partner_code' => Partner24::getBotCode(),
54 'support_partner_name' => Partner24::getPartnerName(),
58 if (Support24::getSupportLevel() === Network::SUPPORT_LEVEL_PAID && Support24::isEnabled())
60 $supportBotId = Support24::getBotId();
62 elseif (SupportBox::isEnabled())
64 $supportBotId = SupportBox::getBotId();
67 $this->parameters[
'support_bot'] = $supportBotId;
70 private function buildExternalParameters(): void
76 foreach (
$event->getResults() as $eventResult)
78 if (($eventParameters = $eventResult->getParameters()) && is_array($eventParameters))
80 $this->parameters = array_merge($this->parameters, $eventParameters);
85 private function buildKeyConfiguration(): void
89 $this->parameters[
'key'] = \CBitrix24::requestSign($this->getHostName() . $this->currentUser->getId());
93 $this->parameters[
'head'] = md5(
'BITRIX' . Application::getInstance()->getLicense()->getKey() .
'LICENCE');
94 $this->parameters[
'key'] = md5($this->getHostName() . $this->currentUser->getId() . $this->parameters[
'head']);
98 private function buildUserCharacteristics(): void
100 $userId = $this->currentUser->getId();
101 $this->parameters += [
102 'is_admin' => ($this->isCloud && \CBitrix24::isPortalAdmin(
$userId))
103 || (!$this->isCloud && $this->currentUser->isAdmin()) ? 1 : 0,
104 'is_integrator' => (int)($this->isCloud && \CBitrix24::isIntegrator(
$userId)),
106 'user_email' => $this->currentUser->getEmail(),
107 'user_name' => $this->currentUser->getFirstName(),
108 'user_last_name' => $this->currentUser->getLastName(),
111 if (Loader::includeModule(
'intranet'))
113 $this->parameters[
'user_date_register'] = \Bitrix\Intranet\CurrentUser::get()->getDateRegister()?->getTimestamp();
115 if (method_exists(Intranet\User::class,
'getUserRole'))
117 $this->parameters[
'user_type'] = (
new Intranet\User())->
getUserRole()->value;
122 private function buildPortalInformation(): void
124 $this->parameters += [
125 'tariff' => Option::get(
'main',
'~controller_group_name',
''),
126 'is_cloud' => $this->isCloud ?
'1' :
'0',
127 'host' => $this->getHostName(),
128 'languageId' => LANGUAGE_ID,
129 'demoStatus' => $this->getDemoStatus(),
130 'isAutoPay' => $this->isCloud && \CBitrix24::isAutoPayLicense(),
135 $this->parameters += [
136 'portal_date_register' => Option::get(
'main',
'~controller_date_create',
''),
137 'canAllUsersBuyTariff' => \CBitrix24::canAllBuyLicense(),
138 'isSidePanelDemoLicense' => Option::get(
'bitrix24',
'isSidePanelDemoLicense') ===
'Y',
143 private function buildHeadInformation(): void
145 if (!Loader::includeModule(
'intranet'))
150 $currentUser = Intranet\CurrentUser::get();
151 $heads = \CIntranetUtils::GetDepartmentManager($currentUser->getDepartmentIds(), $currentUser->getId(),
true);
155 $this->parameters[
'isSubordinate'] = 0;
160 foreach ($heads as $head)
162 if (!empty($head) && isset($head[
'ID']))
164 $this->parameters += [
166 'isSubordinate' => 1,
168 'id' => (int)$head[
'ID'],
169 'name' => \CUser::FormatName(\CSite::GetNameFormat(
false), $head),
170 'avatar' => $this->prepareUserPhoto($head),
180 private function prepareUserPhoto(
array $headData): ?string
182 return $headData[
'PERSONAL_PHOTO'] ? (string)Intranet\Component\UserProfile::getUserPhoto($headData[
'PERSONAL_PHOTO']) :
'';
185 private function getHostName(): ?string
187 if ($this->isCloud && defined(
'BX24_HOST_NAME'))
189 return BX24_HOST_NAME;
192 return Context::getCurrent()?->getRequest()->getHttpHost();
195 private function getDemoStatus(): string
197 if (Loader::includeModule(
'bitrix24'))
199 if (\CBitrix24::IsDemoLicense())
204 if (Bitrix24\Feature::isEditionTrialable(
'demo'))
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)