Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
infohelper.php
1<?
2namespace Bitrix\UI;
3
4use Bitrix\ImBot\Bot\Network;
5use Bitrix\ImBot\Bot\Support24;
6use Bitrix\ImBot\Bot\SupportBox;
12use Bitrix\ImBot\Bot\Partner24;
13use Bitrix\Bitrix24;
14
20{
21 public static function getInitParams(?string $currentUrl = null)
22 {
23 return [
24 'frameUrlTemplate' => self::getUrl('/widget2/show/code/', $currentUrl),
25 'trialableFeatureList' => self::getTrialableFeatureList(),
26 'demoStatus' => self::getDemoStatus(),
27 'availableDomainList' => Util::listDomain(),
28 ];
29 }
30
31 public static function getUrl(string $url = "/widget2/show/code/", ?string $currentUrl = null, bool $byLang = false)
32 {
33 $notifyUrl = Util::getHelpdeskUrl($byLang) . $url;
34 $parameters = self::getParameters($currentUrl);
35
36 return \CHTTP::urlAddParams($notifyUrl, $parameters, array("encode" => true));
37 }
38
39 public static function getParameters(?string $currentUrl = null): array
40 {
41 global $APPLICATION;
42
43 $currentUser = CurrentUser::get();
44 $isBitrix24Cloud = Loader::includeModule('bitrix24');
45 $application = \Bitrix\Main\HttpApplication::getInstance();
46 $host = self::getHostName();
47 $userId = $currentUser->getId();
48 $parameters = [
49 'url' => $currentUrl ?? 'https://' . $_SERVER['HTTP_HOST'] . $APPLICATION->GetCurPageParam(),
50 'is_admin' => ($isBitrix24Cloud && \CBitrix24::isPortalAdmin($userId))
51 || (!$isBitrix24Cloud && $currentUser->isAdmin()) ? 1 : 0,
52 'tariff' => Option::get('main', '~controller_group_name', ''),
53 'is_cloud' => $isBitrix24Cloud ? '1' : '0',
54 'portal_date_register' => $isBitrix24Cloud ? Option::get('main', '~controller_date_create', '') : '',
55 'host' => $host,
56 'languageId' => LANGUAGE_ID,
57 'user_id' => $userId,
58 'user_email' => $currentUser->getEmail(),
59 'user_name' => Encoding::convertEncoding($currentUser->getFirstName(), SITE_CHARSET, 'utf-8'),
60 'user_last_name' => Encoding::convertEncoding($currentUser->getLastName(), SITE_CHARSET, 'utf-8'),
61 ];
62
63 if (Loader::includeModule('intranet'))
64 {
65 $parameters['user_date_register'] = \Bitrix\Intranet\CurrentUser::get()->getDateRegister()?->getTimestamp();
66 }
67
68 if (Loader::includeModule('imbot'))
69 {
70 $parameters['support_partner_code'] = Partner24::getBotCode();
71 $partnerName = Encoding::convertEncoding(Partner24::getPartnerName(), SITE_CHARSET, 'utf-8');
72 $parameters['support_partner_name'] = $partnerName;
73 $supportBotId = 0;
74
75 if (
76 class_exists('\\Bitrix\\ImBot\\Bot\\Support24')
77 && (Support24::getSupportLevel() === Network::SUPPORT_LEVEL_PAID)
78 && Support24::isEnabled()
79 )
80 {
81 $supportBotId = (int)Support24::getBotId();
82 }
83 elseif (
84 method_exists('\\Bitrix\\ImBot\\Bot\\SupportBox', 'isEnabled')
85 && SupportBox::isEnabled()
86 )
87 {
88 $supportBotId = SupportBox::getBotId();
89 }
90
91 $parameters['support_bot'] = $supportBotId;
92 }
93
94 if (!$isBitrix24Cloud)
95 {
96 $parameters['head'] = md5("BITRIX" . $application->getLicense()->getKey() . 'LICENCE');
97 $parameters['key'] = md5($host . $userId . $parameters['head']);
98 }
99 else
100 {
101 $parameters['key'] = \CBitrix24::requestSign($host . $userId);
102 }
103
104 return $parameters;
105 }
106
107 private static function getTrialableFeatureList(): array
108 {
109 if (
110 Loader::includeModule('bitrix24')
111 && method_exists(Bitrix24\Feature::class, 'getTrialableFeatureList')
112 )
113 {
114 return Bitrix24\Feature::getTrialableFeatureList();
115 }
116
117 return [];
118 }
119
120 private static function getDemoStatus(): string
121 {
122 if (Loader::includeModule('bitrix24'))
123 {
124 if (\CBitrix24::IsDemoLicense())
125 {
126 return 'ACTIVE';
127 }
128
129 if (Bitrix24\Feature::isEditionTrialable('demo'))
130 {
131 return 'AVAILABLE';
132 }
133 else
134 {
135 return 'EXPIRED';
136 }
137 }
138
139 return 'UNKNOWN';
140 }
141
142 private static function getHostName()
143 {
144 if (ModuleManager::isModuleInstalled("bitrix24") && defined('BX24_HOST_NAME'))
145 {
146 return BX24_HOST_NAME;
147 }
148
149 $site = \Bitrix\Main\SiteTable::getList(array(
150 'filter' => defined('SITE_ID') ? array('=LID' => SITE_ID) : array(),
151 'order' => array('ACTIVE' => 'DESC', 'DEF' => 'DESC', 'SORT' => 'ASC'),
152 'select' => array('SERVER_NAME'),
153 'cache' => array('ttl' => 86400)
154 ))->fetch();
155
156 return $site['SERVER_NAME'] ?: Option::get('main', 'server_name', '');
157 }
158}
159
static getParameters(?string $currentUrl=null)
static getInitParams(?string $currentUrl=null)
static getUrl(string $url="/widget2/show/code/", ?string $currentUrl=null, bool $byLang=false)
static getHelpdeskUrl($byLang=false)
Definition util.php:26
static listDomain()
Definition util.php:82