1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Notify.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Settings\Entity;
4
5use Bitrix\Im\Configuration\Notification;
6
7class Notify extends BaseSettings
8{
9
10 public static function getRestEntityName(): string
11 {
12 return 'notify';
13 }
14
15 public function toRestFormat(array $option = []): array
16 {
17 if (!$this->isLoad())
18 {
19 $this->load($this->groupId);
20 }
21
22 $notifyNames = Notification::getEventNames();
23 $result = [];
24 foreach ($this->settings as $moduleId => $moduleConfig)
25 {
26 if (!isset($notifyNames[$moduleId]))
27 {
28 continue;
29 }
30
31 $newModuleConfig = [
32 'id' => $moduleId,
33 'label' => $notifyNames[$moduleId]['NAME'],
34 'notices' => [],
35 ];
36
37 $notices = [];
38 foreach ($moduleConfig['NOTIFY'] as $eventName => $eventConfig)
39 {
40 $notify = [
41 'id' => $eventName,
42 'label' => $eventConfig['NAME'],
43 'site' => $eventConfig['SITE'],
44 'mail' => $eventConfig['MAIL'],
45 'push' => $eventConfig['PUSH'],
46 'disabled' => [],
47 ];
48
49 $disabled = [];
50 foreach ($eventConfig['DISABLED'] as $disableType => $value)
51 {
52 if ($disableType === 'XMPP')
53 {
54 continue;
55 }
56 if ($value)
57 {
58 $disabled[] = mb_strtolower($disableType);
59 }
60 }
61 $notify['disabled'] = $disabled;
62
63 $notices[] = $notify;
64 }
65 $newModuleConfig['notices'] = $notices;
66 $result[] = $newModuleConfig;
67 }
68
69 return $result;
70 }
71
76 public function updateSetting(array $settingConfiguration)
77 {
78 $moduleId = $settingConfiguration['moduleId'];
79 $name = $settingConfiguration['name'];
80 $type = $settingConfiguration['type'];
81 $value = $settingConfiguration['value'];
82
83 $updatingSetting = [
84 $moduleId => [[
85 $name => [
86 $type => $value,
87 ],
88 ]],
89 ];
90
91 $defaultSettings = Notification::getDefaultSettings();
92 if ($defaultSettings[$moduleId]['NOTIFY'][$name]['DISABLED'][mb_strtoupper($type)] ?? true)
93 {
94 return;
95 }
96
97 $this->settings[$moduleId]['NOTIFY'][$name][mb_strtoupper($type)] = $settingConfiguration['value'];
98 Notification::updateGroupSettings($this->groupId, $updatingSetting);
99 }
100
101 public function updateSimpleSettings(array $simpleSchema): Notify
102 {
103 $this->settings = Notification::getSimpleNotifySettings($simpleSchema);
104
105 Notification::updateGroupSettings($this->groupId, $this->settings);
106
107 return $this;
108 }
109
115 public function fillDataBase(bool $isSimpleSchema = false, array $simpleSchema = []): BaseSettings
116 {
117 if ($isSimpleSchema)
118 {
119 $this->settings = Notification::getSimpleNotifySettings($simpleSchema);
120 }
121 else
122 {
123 $this->settings = Notification::getDefaultSettings();
124 }
125 Notification::setSettings($this->groupId, $this->settings);
126
127 return $this;
128 }
129
130 public function load($source): BaseSettings
131 {
132 if (is_int($source))
133 {
134 $this->settings = Notification::getGroupSettings($this->groupId);
135 $this->isLoad = true;
136
137 return $this;
138 }
139
140 if (is_array($source) && !empty($source))
141 {
142 $this->settings = Notification::filterGroupSettingsByDefault($source);
143 $this->isLoad = true;
144 }
145
146 return $this;
147 }
148}
$type
Определения options.php:106
static getRestEntityName()
Определения Notify.php:10
toRestFormat(array $option=[])
Определения Notify.php:15
updateSetting(array $settingConfiguration)
Определения Notify.php:76
updateSimpleSettings(array $simpleSchema)
Определения Notify.php:101
load($source)
Определения Notify.php:130
fillDataBase(bool $isSimpleSchema=false, array $simpleSchema=[])
Определения Notify.php:115
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$moduleId
$name
Определения menu_edit.php:35
$option
Определения options.php:1711