Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
configcomponent.php
1
<?php
2
3
namespace
Bitrix\Main\UserField
;
4
5
use
Bitrix\Main\Application
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\ErrorCollection
;
8
use
Bitrix\Main\Localization\Loc
;
9
10
abstract
class
ConfigComponent
extends
\CBitrixComponent
11
{
12
public
const
ERROR_CODE_NO_MODULE_ERROR
=
'UF_CONFIG_NO_MODULE'
;
13
15
protected
$access
;
16
protected
$entityId
=
''
;
17
protected
$moduleId
;
19
protected
$errorCollection
;
20
protected
$userTypes
;
21
22
protected
function
init
(): void
23
{
24
$this->errorCollection =
new
ErrorCollection
();
25
26
$request =
Application::getInstance
()->getContext()->getRequest();
27
$this->entityId = !empty($this->arParams[
'entityId'
]) ? $this->arParams[
'entityId'
] : $request->get(
'entityId'
);
28
$this->moduleId = !empty($this->arParams[
'moduleId'
]) ? $this->arParams[
'moduleId'
] : $request->get(
'moduleId'
);
29
30
if
(!$this->moduleId)
31
{
32
$this->errorCollection[] = $this->
getNoModuleError
();
33
return
;
34
}
35
$this->access =
UserFieldAccess::getInstance
($this->moduleId);
36
}
37
38
protected
function
getNoModuleError
():
Error
39
{
40
return
new
Error
(
Loc::getMessage
(
'MAIN_USER_FIELD_CONFIG_COMPONENT_NO_MODULE_ERROR'
), static::ERROR_CODE_NO_MODULE_ERROR);
41
}
42
43
protected
function
getAccessDeniedError
():
Error
44
{
45
return
new
Error
(
Loc::getMessage
(
'MAIN_USER_FIELD_CONFIG_COMPONENT_ACCESS_DENIED_ERROR'
), static::ERROR_CODE_NO_MODULE_ERROR);
46
}
47
48
protected
function
getUserTypes
(): array
49
{
50
if
(!$this->userTypes)
51
{
52
global $USER_FIELD_MANAGER;
53
$this->userTypes = $USER_FIELD_MANAGER->GetUserType();
54
$restrictedTypes = $this->access->getRestrictedTypes();
55
foreach
($restrictedTypes as $typeId)
56
{
57
unset($this->userTypes[$typeId]);
58
}
59
}
60
61
return
$this->userTypes
;
62
}
63
64
protected
function
setTitle
(
string
$title): void
65
{
66
global $APPLICATION;
67
68
$APPLICATION->SetTitle($title);
69
}
70
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getInstance
static getInstance()
Definition
application.php:95
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\UserField\ConfigComponent
Definition
configcomponent.php:11
Bitrix\Main\UserField\ConfigComponent\getAccessDeniedError
getAccessDeniedError()
Definition
configcomponent.php:43
Bitrix\Main\UserField\ConfigComponent\init
init()
Definition
configcomponent.php:22
Bitrix\Main\UserField\ConfigComponent\$errorCollection
$errorCollection
Definition
configcomponent.php:19
Bitrix\Main\UserField\ConfigComponent\setTitle
setTitle(string $title)
Definition
configcomponent.php:64
Bitrix\Main\UserField\ConfigComponent\getUserTypes
getUserTypes()
Definition
configcomponent.php:48
Bitrix\Main\UserField\ConfigComponent\$userTypes
$userTypes
Definition
configcomponent.php:20
Bitrix\Main\UserField\ConfigComponent\getNoModuleError
getNoModuleError()
Definition
configcomponent.php:38
Bitrix\Main\UserField\ConfigComponent\$moduleId
$moduleId
Definition
configcomponent.php:17
Bitrix\Main\UserField\ConfigComponent\$access
$access
Definition
configcomponent.php:15
Bitrix\Main\UserField\ConfigComponent\$entityId
$entityId
Definition
configcomponent.php:16
Bitrix\Main\UserField\ConfigComponent\ERROR_CODE_NO_MODULE_ERROR
const ERROR_CODE_NO_MODULE_ERROR
Definition
configcomponent.php:12
Bitrix\Main\UserField\UserFieldAccess\getInstance
static getInstance(string $moduleId, int $userId=null)
Definition
userfieldaccess.php:28
Bitrix\Main\UserField
modules
main
lib
userfield
configcomponent.php
Создано системой
1.10.0