1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
showcaseparams.php
См. документацию.
1<?php
2
4
13
14final class ShowcaseParams
15{
16 private const PATH_MAIL_CONFIG = '/mail/config/';
17 private const MAILBOX_LIMIT_SLIDER_CODE = 'limit_contact_center_mail_box_number';
18
19 private const RU_REGION_CODE = 'ru';
20 private const IMAP_TYPE = 'imap';
21 private const RU_PROVIDERS_LIST = ['yandex', 'mailru', 'office365', 'gmail'];
22 private const WORLD_PROVIDER_LIST = ['gmail', 'icloud', 'office365', 'yahoo'];
23
24 private bool $isSenderShowcase;
25 private ?string $region;
26
27 public function __construct(bool $isSenderShowcase)
28 {
29 $this->isSenderShowcase = $isSenderShowcase;
30 $this->region = Application::getInstance()->getLicense()->getRegion();
31 }
32
33 public function getParams(): array
34 {
35 $isCloud = false;
36 if (!Loader::includeModule('mail'))
37 {
38 return [
39 'options' => [
40 'isModuleMailInstalled' => false,
41 'promotionProviders' => $this->getPromotionProviders(),
42 'isSmtpAvailable' => $this->isSmtpAvailable(),
43 'isCloud' => $isCloud,
44 ],
45 ];
46 }
47
48 $intranetToolSettings = $this->getIntranetToolSettings();
49 extract($intranetToolSettings, EXTR_OVERWRITE);
50 $canConnectNewMailbox = Mailbox\MailboxConnector::canConnectNewMailbox();
51 $providers = $this->getProviders();
52
53 return [
54 'options' => [
55 'isModuleMailInstalled' => true,
56 'canConnectNewMailbox' => $canConnectNewMailbox,
57 'mailboxLimitSliderCode' => self::MAILBOX_LIMIT_SLIDER_CODE,
58 'isMailToolAvailable' => $isMailToolAvailable ?? false,
59 'toolLimitSliderCode' => $toolLimitSliderCode ?? null,
60 'isSmtpAvailable' => $this->isSmtpAvailable(),
61 'isCloud' => $isCloud,
62 ],
63 'providers' => $providers,
64 ];
65 }
66
67 private function getIntranetToolSettings(): array
68 {
69 if (class_exists('\Bitrix\Mail\Integration\Intranet\ToolShowSettings'))
70 {
71 $toolShowSettings = new Mail\Integration\Intranet\ToolShowSettings();
72
73 return [
74 'isMailToolAvailable' => $toolShowSettings->isMailAvailable(),
75 'toolLimitSliderCode' => $toolShowSettings->getMailLimitSliderCode(),
76 ];
77 }
78
79 return [
80 'isMailToolAvailable' => true,
81 'toolLimitSliderCode' => null,
82 ];
83 }
84
85 private function getProviders(): array
86 {
87 if (!Loader::includeModule('intranet'))
88 {
89 return [];
90 }
91
92 $services = Mailbox::getServices();
93 $providers = [];
94 foreach ($services as $service)
95 {
96 if ($service['type'] !== self::IMAP_TYPE)
97 {
98 continue;
99 }
100
101 $uri = new Uri(self::PATH_MAIL_CONFIG . 'new');
102 if ($this->isSenderShowcase)
103 {
104 $uri->addParams(['smtp' => 'Y']);
105 }
106
107 $providers[] = [
108 'href' => $uri->addParams(['id' => $service['id']]),
109 'icon' => $service['icon'],
110 'name' => $service['name'],
111 ];
112 }
113
114 return $providers;
115 }
116
117 private function getPromotionProviders(): array
118 {
119 if (!$this->region)
120 {
121 return self::WORLD_PROVIDER_LIST;
122 }
123
124 return (Localization\Loc::getDefaultLang($this->region) === self::RU_REGION_CODE) ? self::RU_PROVIDERS_LIST : self::WORLD_PROVIDER_LIST;
125 }
126
127 private function isSmtpAvailable(): bool
128 {
129 $defaultMailConfiguration = Configuration::getValue('smtp');
130 return Loader::includeModule('bitrix24')
131 || $defaultMailConfiguration['enabled']
132 ;
133 }
134}
static getInstance()
Определения application.php:98
Определения loader.php:13
static includeModule($moduleName)
Определения loader.php:67
__construct(bool $isSenderShowcase)
Определения showcaseparams.php:27
Определения uri.php:17
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения urlrewrite.php:61
Определения blacklist.php:3
$service
Определения payment.php:18