1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
push.php
См. документацию.
1<?php
2namespace Bitrix\Pull;
3
4class Push
5{
6 static $types = null;
7 static $config = array();
8 protected static array $explodedOptionIdsStaticCache = [];
9
10 public static function add($users, $parameters)
11 {
12 unset($parameters['command']);
13 unset($parameters['params']);
14 return \Bitrix\Pull\Event::add($users, $parameters);
15 }
16
17 public static function send()
18 {
19 return \Bitrix\Pull\Event::send();
20 }
21
22 public static function getTypes()
23 {
24 if (is_array(self::$types))
25 {
26 return self::$types;
27 }
28
29 if (!\Bitrix\Main\Loader::includeModule('im'))
30 {
31 return Array();
32 }
33
34 $notifySchema = \CIMNotifySchema::GetNotifySchema();
35
36 $result = Array();
37 foreach ($notifySchema as $moduleId => $module)
38 {
39 if ($module['NAME'] == '')
40 {
41 $info = \CModule::CreateModuleObject($moduleId);
42 $name= $info->MODULE_NAME;
43 }
44 else
45 {
46 $name = $module['NAME'];
47 }
48
49 $types = Array();
50 foreach ($module['NOTIFY'] as $notifyType => $notifyConfig)
51 {
52 if (!$notifyConfig['PUSH'] && $notifyConfig['DISABLED']['PUSH'])
53 {
54 continue;
55 }
56 $types[$notifyType] = Array(
57 'NAME' => $notifyConfig['NAME'],
58 'TYPE' => $notifyType,
59 'DISABLED' => (bool)$notifyConfig['DISABLED']['PUSH'],
60 'DEFAULT' => (bool)$notifyConfig['PUSH'],
61 );
62 }
63 if (empty($types))
64 {
65 continue;
66 }
67
68 $result[$moduleId] = Array(
69 'NAME' => $name,
70 'MODULE_ID' => $moduleId,
71 'TYPES' => $types
72 );
73 }
74
75 self::$types = $result;
76
77 return $result;
78 }
79
80 public static function getConfig($userId = null)
81 {
82 if (!\Bitrix\Main\Loader::includeModule('im'))
83 {
84 return Array();
85 }
86
87 if (is_null($userId) && is_object($GLOBALS['USER']))
88 {
89 $userId = $GLOBALS['USER']->getId();
90 }
91
92 $userId = intval($userId);
93 if (!$userId)
94 {
95 return false;
96 }
97
98 if (isset(self::$config[$userId]))
99 {
100 return self::$config[$userId];
101 }
102
103 $pushDisabled = !\Bitrix\Pull\Push::getStatus($userId);
104
105 $userOptions = \CIMSettings::Get($userId)[\CIMSettings::NOTIFY] ?? [];
106
107 $result = Array();
108 foreach ($userOptions as $optionId => $optionValue)
109 {
110 self::$explodedOptionIdsStaticCache[$optionId] ??= explode('|', $optionId);
111 [$clientId, $moduleId, $type] = self::$explodedOptionIdsStaticCache[$optionId];
112
114 {
115 continue;
116 }
117
119 }
120
121 $notifySchema = \CIMNotifySchema::GetNotifySchema();
122
123 foreach ($notifySchema as $moduleId => $module)
124 {
125 foreach ($module['NOTIFY'] as $notifyType => $notifyConfig)
126 {
127 if ($pushDisabled)
128 {
129 $result[$moduleId][$notifyType] = false;
130 continue;
131 }
132
133 if (!$notifyConfig['PUSH'] && $notifyConfig['DISABLED']['PUSH'])
134 {
135 continue;
136 }
137
138 if (!isset($result[$moduleId][$notifyType]) || $notifyConfig['DISABLED']['PUSH'])
139 {
140 $result[$moduleId][$notifyType] = (bool)$notifyConfig['PUSH'];
141 }
142 }
143 }
144
145 self::$config[$userId] = $result;
146
147 return $result;
148 }
149
150 public static function setConfig($config, $userId = null)
151 {
152 if (!\Bitrix\Main\Loader::includeModule('im'))
153 {
154 return false;
155 }
156
157 if (!is_array($config))
158 {
159 return false;
160 }
161
162 if (is_null($userId) && is_object($GLOBALS['USER']))
163 {
164 $userId = $GLOBALS['USER']->getId();
165 }
166 $userId = intval($userId);
167 if ($userId <= 0)
168 {
169 return false;
170 }
171
172 $types = self::getTypes();
173 $userConfig = self::getConfig($userId);
174 $userOptions = \CIMSettings::Get($userId)[\CIMSettings::NOTIFY] ?? [];
175
176 $needUpdate = false;
177 foreach ($types as $moduleId => $module)
178 {
179 foreach ($module['TYPES'] as $typeId => $type)
180 {
181 if (isset($config[$moduleId][$typeId]))
182 {
183 $needUpdate = true;
184 $userConfig[$moduleId][$typeId] = (bool)$config[$moduleId][$typeId];
185 }
186 if ($type['DEFAULT'] == $userConfig[$moduleId][$typeId])
187 {
188 unset($userOptions['push|'.$moduleId.'|'.$typeId]);
189 }
190 else
191 {
192 $userOptions['push|'.$moduleId.'|'.$typeId] = $userConfig[$moduleId][$typeId];
193 }
194 }
195 }
196
197 if ($needUpdate)
198 {
201 unset(self::$config[$userId]);
202 }
203
204 return true;
205 }
206
207 public static function setConfigTypeStatus($moduleId, $typeId, $status, $userId = null)
208 {
209 return self::setConfig(Array($moduleId => Array($typeId => $status)), $userId);
210 }
211
212 public static function getConfigTypeStatus($moduleId, $typeId, $userId = null)
213 {
214 $config = self::getConfig($userId);
215 return isset($config[$moduleId][$typeId])? $config[$moduleId][$typeId]: true;
216 }
217
218 public static function getStatus($userId = null)
219 {
220 if (!\CPullOptions::GetPushStatus())
221 {
222 return null;
223 }
224
225 if (is_null($userId) && is_object($GLOBALS['USER']))
226 {
227 $userId = $GLOBALS['USER']->getId();
228 }
229 $userId = intval($userId);
230 if (!$userId)
231 {
232 return false;
233 }
234
235 return (bool)\CUserOptions::GetOption('pull', 'push_status', true, $userId);
236 }
237
238 public static function setStatus($status, $userId = null)
239 {
240 if (!\CPullOptions::GetPushStatus())
241 {
242 return null;
243 }
244
245 if (is_null($userId) && is_object($GLOBALS['USER']))
246 {
247 $userId = $GLOBALS['USER']->getId();
248 }
249 $userId = intval($userId);
250 if (!$userId)
251 {
252 return false;
253 }
254
255 $status = $status === false? false: true;
256
257 return (bool)\CUserOptions::SetOption('pull', 'push_status', $status, false, $userId);
258 }
259}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static array $explodedOptionIdsStaticCache
Определения push.php:8
static setConfig($config, $userId=null)
Определения push.php:150
static getTypes()
Определения push.php:22
static setConfigTypeStatus($moduleId, $typeId, $status, $userId=null)
Определения push.php:207
static $config
Определения push.php:7
static getConfigTypeStatus($moduleId, $typeId, $userId=null)
Определения push.php:212
static send()
Определения push.php:17
static getStatus($userId=null)
Определения push.php:218
static $types
Определения push.php:6
static getConfig($userId=null)
Определения push.php:80
static add($users, $parameters)
Определения push.php:10
static setStatus($status, $userId=null)
Определения push.php:238
static GetNotifySchema()
Определения im_notify_schema.php:15
static ClearCache($userId=false)
Определения im_settings.php:544
const NOTIFY
Определения im_settings.php:13
const CLIENT_PUSH
Определения im_settings.php:18
static Set($type, $value, $userId=false)
Определения im_settings.php:73
static Get($userId=false)
Определения im_settings.php:34
</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
$status
Определения session.php:10
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
$name
Определения menu_edit.php:35
$GLOBALS['____1690880296']
Определения license.php:1
$optionValue
Определения options.php:3512
$clientId
Определения seo_client.php:18