1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
infohelper.php
См. документацию.
1<?php
2namespace Bitrix\UI;
3
4use Bitrix\ImBot\Bot\Network;
5use Bitrix\ImBot\Bot\Support24;
6use Bitrix\ImBot\Bot\SupportBox;
7use Bitrix\Main\Config\Option;
8use Bitrix\Main\Engine\CurrentUser;
9use Bitrix\Main\Loader;
10use Bitrix\Main\Event;
11use Bitrix\Main\ModuleManager;
12use Bitrix\ImBot\Bot\Partner24;
13use Bitrix\Bitrix24;
14
21{
22 public static function getInitParams(?string $currentUrl = null)
23 {
24 return [
25 'frameUrlTemplate' => self::getUrl('/widget2/show/code/', $currentUrl),
26 'trialableFeatureList' => self::getTrialableFeatureList(),
27 'demoStatus' => self::getDemoStatus(),
28 'availableDomainList' => Util::listDomain(),
29 ];
30 }
31
32 public static function getUrl(string $url = "/widget2/show/code/", ?string $currentUrl = null, bool $byLang = false)
33 {
34 $notifyUrl = Util::getHelpdeskUrl($byLang) . $url;
35 $parameters = self::getParameters($currentUrl);
36
37 return \CHTTP::urlAddParams($notifyUrl, $parameters, array("encode" => true));
38 }
39
40 public static function getParameters(?string $currentUrl = null): array
41 {
42 global $APPLICATION;
43
44 $currentUser = CurrentUser::get();
45 $isBitrix24Cloud = Loader::includeModule('bitrix24');
47 $host = self::getHostName();
48 $userId = $currentUser->getId();
49 $parameters = [
50 'url' => $currentUrl ?? 'https://' . $_SERVER['HTTP_HOST'] . $APPLICATION->GetCurPageParam(),
51 'is_admin' => ($isBitrix24Cloud && \CBitrix24::isPortalAdmin($userId))
52 || (!$isBitrix24Cloud && $currentUser->isAdmin()) ? 1 : 0,
53 'is_integrator' => (int)($isBitrix24Cloud && \CBitrix24::isIntegrator($userId)),
54 'tariff' => Option::get('main', '~controller_group_name', ''),
55 'is_cloud' => $isBitrix24Cloud ? '1' : '0',
56 'portal_date_register' => $isBitrix24Cloud ? Option::get('main', '~controller_date_create', '') : '',
57 'host' => $host,
58 'languageId' => LANGUAGE_ID,
59 'user_id' => $userId,
60 'user_email' => $currentUser->getEmail(),
61 'user_name' => $currentUser->getFirstName(),
62 'user_last_name' => $currentUser->getLastName(),
63 ];
64
65 if (Loader::includeModule('intranet'))
66 {
67 $parameters['user_date_register'] = \Bitrix\Intranet\CurrentUser::get()->getDateRegister()?->getTimestamp();
68
69 if (method_exists(\Bitrix\Intranet\User::class, 'getUserRole'))
70 {
71 $parameters['user_type'] = (new \Bitrix\Intranet\User())->getUserRole()->value;
72 }
73 }
74
75 if (Loader::includeModule('imbot'))
76 {
77 $parameters['support_partner_code'] = Partner24::getBotCode();
78 $partnerName = Partner24::getPartnerName();
79 $parameters['support_partner_name'] = $partnerName;
80 $supportBotId = 0;
81
82 if (
83 class_exists('\\Bitrix\\ImBot\\Bot\\Support24')
84 && (Support24::getSupportLevel() === Network::SUPPORT_LEVEL_PAID)
85 && Support24::isEnabled()
86 )
87 {
88 $supportBotId = (int)Support24::getBotId();
89 }
90 elseif (
91 method_exists('\\Bitrix\\ImBot\\Bot\\SupportBox', 'isEnabled')
92 && SupportBox::isEnabled()
93 )
94 {
95 $supportBotId = SupportBox::getBotId();
96 }
97
98 $parameters['support_bot'] = $supportBotId;
99 }
100
101 if (!$isBitrix24Cloud)
102 {
103 $parameters['head'] = md5("BITRIX" . $application->getLicense()->getKey() . 'LICENCE');
104 $parameters['key'] = md5($host . $userId . $parameters['head']);
105 }
106 else
107 {
108 $parameters['key'] = \CBitrix24::requestSign($host . $userId);
109 }
110
111 $method = "\\" . __METHOD__;
112
113 $event = (new Event('ui', $method, $parameters));
114 $event->send();
115 foreach ($event->getResults() as $eventResult)
116 {
117 if (($eventParameters = $eventResult->getParameters()) && is_array($eventParameters))
118 {
119 $parameters = array_merge($parameters, $eventParameters);
120 }
121 }
122
123 return $parameters;
124 }
125
126 private static function getTrialableFeatureList(): array
127 {
128 if (
129 Loader::includeModule('bitrix24')
130 && method_exists(Bitrix24\Feature::class, 'getTrialableFeatureList')
131 )
132 {
133 return Bitrix24\Feature::getTrialableFeatureList();
134 }
135
136 return [];
137 }
138
139 private static function getDemoStatus(): string
140 {
141 if (Loader::includeModule('bitrix24'))
142 {
143 if (\CBitrix24::IsDemoLicense())
144 {
145 return 'ACTIVE';
146 }
147
148 if (Bitrix24\Feature::isEditionTrialable('demo'))
149 {
150 return 'AVAILABLE';
151 }
152 else
153 {
154 return 'EXPIRED';
155 }
156 }
157
158 return 'UNKNOWN';
159 }
160
161 private static function getHostName()
162 {
163 if (ModuleManager::isModuleInstalled("bitrix24") && defined('BX24_HOST_NAME'))
164 {
165 return BX24_HOST_NAME;
166 }
167
168 $site = \Bitrix\Main\SiteTable::getList(array(
169 'filter' => defined('SITE_ID') ? array('=LID' => SITE_ID) : array(),
170 'order' => array('ACTIVE' => 'DESC', 'DEF' => 'DESC', 'SORT' => 'ASC'),
171 'select' => array('SERVER_NAME'),
172 'cache' => array('ttl' => 86400)
173 ))->fetch();
174
175 return $site['SERVER_NAME'] ?: Option::get('main', 'server_name', '');
176 }
177}
178
global $APPLICATION
Определения include.php:80
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance()
Определения application.php:98
Определения event.php:5
static getParameters(?string $currentUrl=null)
Определения infohelper.php:40
static getInitParams(?string $currentUrl=null)
Определения infohelper.php:22
static getUrl(string $url="/widget2/show/code/", ?string $currentUrl=null, bool $byLang=false)
Определения infohelper.php:32
static getHelpdeskUrl($byLang=false)
Определения util.php:26
static listDomain()
Определения util.php:82
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$host
Определения .description.php:9
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$application
Определения bitrix.php:23
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$method
Определения index.php:27
const SITE_ID
Определения sonet_set_content_view.php:12
$url
Определения iframe.php:7
$site
Определения yandex_run.php:614