1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PopupProviderAvailabilityChecker.php
См. документацию.
1<?php
2
3namespace Bitrix\UI\FeaturePromoter;
4
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\Loader;
7
9{
10 private const MODULE_ID = 'ui';
11 private const ACCESS_OPTION_NAME = 'info-helper-popup-provider';
12 private const AVAILABLE_ZONES = ['ru', 'by'];
13 private const UNDEFINED_OPTION_STATUS = 'undefined';
14 private const DISABLED_OPTION_STATUS = 'N';
15 private const ENABLED_OPTION_STATUS = 'Y';
16
17 public function isAvailable(): bool
18 {
19 if (!Loader::includeModule('bitrix24'))
20 {
21 return false;
22 }
23
24 if ($this->isUnavailableByOption())
25 {
26 return false;
27 }
28
29 return $this->isAvailableByRegion() || $this->isAvailableByOption();
30 }
31
32 private function isAvailableByOption(): bool
33 {
34 return Option::get(self::MODULE_ID, self::ACCESS_OPTION_NAME, self::UNDEFINED_OPTION_STATUS)
35 === self::ENABLED_OPTION_STATUS;
36 }
37
38 private function isUnavailableByOption(): bool
39 {
40 return Option::get(self::MODULE_ID, self::ACCESS_OPTION_NAME, self::UNDEFINED_OPTION_STATUS)
41 === self::DISABLED_OPTION_STATUS;
42 }
43
44 private function isAvailableByRegion(): bool
45 {
46 return in_array(\CBitrix24::getPortalZone(), self::AVAILABLE_ZONES);
47 }
48}