Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
useroption.php
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
Bitrix\Main\Controller
;
6
7
use
Bitrix\Main\Engine
;
8
use
Bitrix\Main\Engine\ActionFilter
;
9
use
Bitrix\Main\Error
;
10
18
class
UserOption
extends
Engine\JsonController
19
{
20
public
const
ERROR_USER_NOT_AUTHORIZED
=
'ERROR_USER_NOT_AUTHORIZED'
;
21
22
protected
function
getDefaultPreFilters
(): array
23
{
24
return
array_merge(
25
parent::getDefaultPreFilters(),
26
[
27
new
ActionFilter\
CloseSession
(),
28
new
ActionFilter\
HttpMethod
(
29
[ActionFilter\
HttpMethod::METHOD_POST
],
30
),
31
]
32
);
33
}
34
35
public
function
saveOptionsAction
(array $newValues): void
36
{
37
\CUserOptions::SetOptionsFromArray($newValues);
38
}
39
40
public
function
deleteOptionAction
(
string
$category,
string
$name,
bool
$common =
false
): void
41
{
42
if
(!(
$GLOBALS
[
"USER"
] instanceof \CUser))
43
{
44
$this->
addError
(
new
Error
(
'User is not authorized'
, self::ERROR_USER_NOT_AUTHORIZED));
45
46
return
;
47
}
48
49
$currentUser =
$GLOBALS
[
"USER"
];
50
if
($common && !$currentUser->CanDoOperation(
'edit_other_settings'
))
51
{
52
$common =
false
;
53
}
54
55
\CUserOptions::DeleteOption(
56
$category,
57
$name,
58
$common,
59
$currentUser->getId()
60
);
61
}
62
}
Bitrix\Main\Controller\UserOption
Definition
useroption.php:19
Bitrix\Main\Controller\UserOption\getDefaultPreFilters
getDefaultPreFilters()
Definition
useroption.php:22
Bitrix\Main\Controller\UserOption\deleteOptionAction
deleteOptionAction(string $category, string $name, bool $common=false)
Definition
useroption.php:40
Bitrix\Main\Controller\UserOption\ERROR_USER_NOT_AUTHORIZED
const ERROR_USER_NOT_AUTHORIZED
Definition
useroption.php:20
Bitrix\Main\Controller\UserOption\saveOptionsAction
saveOptionsAction(array $newValues)
Definition
useroption.php:35
Bitrix\Main\Engine\ActionFilter\CloseSession
Definition
closesession.php:13
Bitrix\Main\Engine\ActionFilter\HttpMethod
Definition
httpmethod.php:13
Bitrix\Main\Engine\ActionFilter\HttpMethod\METHOD_POST
const METHOD_POST
Definition
httpmethod.php:15
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Engine\JsonController
Definition
jsoncontroller.php:9
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Controller
Definition
agreement.php:2
Bitrix\Main\Engine\ActionFilter
Definition
authentication.php:4
Bitrix\Main\Engine
Definition
action.php:3
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
modules
main
lib
controller
useroption.php
Создано системой
1.10.0