Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Notify.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Controller\Settings
;
4
5
use
Bitrix\Im\V2\Controller\BaseController
;
6
use
Bitrix\Im\V2\Controller\Filter\SettingsCheckAccess
;
7
use
Bitrix\Im\V2\Settings\SettingsError
;
8
use
Bitrix\Im\V2\Settings\UserConfiguration
;
9
use
Bitrix\Main\Engine\CurrentUser
;
10
11
class
Notify
extends
BaseController
12
{
13
public
const
ALLOWED_SCHEME
= [
'simple'
,
'expert'
];
14
15
protected
function
getDefaultPreFilters
()
16
{
17
return
array_merge(
18
parent::getDefaultPreFilters(),
19
[
20
new
SettingsCheckAccess
(),
21
]
22
);
23
}
24
25
public
function
listAction
(
int
$userId)
26
{
27
$userConfiguration =
new
UserConfiguration
($userId);
28
29
return
$userConfiguration->getNotifySettings();
30
}
31
32
public
function
updateAction
(
int
$userId,
string
$moduleId,
string
$name,
string
$type,
string
$value)
33
{
34
$userConfiguration =
new
UserConfiguration
($userId);
35
$userConfiguration->updateNotifySetting([
36
'name'
=> $name,
37
'value'
=> $this->
convertCharToBool
($value),
38
'moduleId'
=> $moduleId,
39
'type'
=> $type
40
]);
41
42
return
true
;
43
}
44
48
public
function
switchSchemeAction
(
string
$scheme,
CurrentUser
$currentUser, ?
int
$userId =
null
): ?array
49
{
50
if
(!in_array($scheme, self::ALLOWED_SCHEME,
true
))
51
{
52
$this->
addError
(
new
SettingsError
(SettingsError::WRONG_SCHEME));
53
54
return
null
;
55
}
56
57
$userId ??= (int)$currentUser->
getId
();
58
$userConfiguration =
new
UserConfiguration
($userId);
59
$userConfiguration->updateGeneralSetting([
60
'name'
=> \
Bitrix
\Im\V2\
Settings
\
Entity
\General::SCHEME,
61
'value'
=> $scheme,
62
]);
63
64
return
$userConfiguration->getNotifySettings();
65
}
66
}
Bitrix\Im\Settings
Definition
settings.php:8
Bitrix\Im\V2\Controller\BaseController
Definition
BaseController.php:24
Bitrix\Im\V2\Controller\BaseController\convertCharToBool
convertCharToBool(string $char, bool $default=false)
Definition
BaseController.php:132
Bitrix\Im\V2\Controller\Filter\SettingsCheckAccess
Definition
SettingsCheckAccess.php:12
Bitrix\Im\V2\Controller\Settings\Notify
Definition
Notify.php:12
Bitrix\Im\V2\Controller\Settings\Notify\getDefaultPreFilters
getDefaultPreFilters()
Definition
Notify.php:15
Bitrix\Im\V2\Controller\Settings\Notify\switchSchemeAction
switchSchemeAction(string $scheme, CurrentUser $currentUser, ?int $userId=null)
Definition
Notify.php:48
Bitrix\Im\V2\Controller\Settings\Notify\updateAction
updateAction(int $userId, string $moduleId, string $name, string $type, string $value)
Definition
Notify.php:32
Bitrix\Im\V2\Controller\Settings\Notify\listAction
listAction(int $userId)
Definition
Notify.php:25
Bitrix\Im\V2\Controller\Settings\Notify\ALLOWED_SCHEME
const ALLOWED_SCHEME
Definition
Notify.php:13
Bitrix\Im\V2\Settings\SettingsError
Definition
SettingsError.php:9
Bitrix\Im\V2\Settings\UserConfiguration
Definition
UserConfiguration.php:17
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Engine\CurrentUser
Definition
currentuser.php:8
Bitrix\Main\Engine\CurrentUser\getId
getId()
Definition
currentuser.php:45
Bitrix\Im\V2\Entity
Definition
Entity.php:6
Bitrix\Im\V2\Controller\Settings
Definition
General.php:3
Bitrix
modules
im
lib
V2
Controller
Settings
Notify.php
Создано системой
1.10.0