Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
IblockCatalogPermissions.php
1
<?php
2
3
namespace
Bitrix\Catalog\Access\Permission\Catalog
;
4
5
use
Bitrix\Catalog\Access\Permission\PermissionDictionary
;
6
use
Bitrix\Main\Loader
;
7
13
class
IblockCatalogPermissions
14
{
15
private
bool
$canRead =
false
;
16
private
bool
$canWrite =
false
;
17
private
bool
$canFullAccess =
false
;
24
private
array $accessCodes;
25
private
array $deleteAccessCodes;
26
31
public
function
__construct
(array $accessCodes, array $deleteAccessCodes = [])
32
{
33
Loader::requireModule(
'iblock'
);
34
35
$this->accessCodes = $accessCodes;
36
$this->deleteAccessCodes = $deleteAccessCodes;
37
}
38
46
public
function
setRights
(array $rights): void
47
{
48
foreach
($rights as $item)
49
{
50
if
(!is_array($item))
51
{
52
continue
;
53
}
54
55
$id = (int)($item[
'id'
] ?? 0);
56
if
(empty($id))
57
{
58
continue
;
59
}
60
61
$value = (int)($item[
'value'
] ?? 0);
62
if
(empty($value))
63
{
64
continue
;
65
}
66
67
if
(
68
$id ===
PermissionDictionary::CATALOG_PRODUCT_READ
69
)
70
{
71
$this->canRead =
true
;
72
}
73
elseif (
74
$id ===
PermissionDictionary::CATALOG_PRODUCT_ADD
75
|| $id ===
PermissionDictionary::CATALOG_PRODUCT_EDIT
76
|| $id ===
PermissionDictionary::CATALOG_PRODUCT_DELETE
77
)
78
{
79
$this->canWrite =
true
;
80
}
81
elseif ($id ===
PermissionDictionary::CATALOG_SETTINGS_ACCESS
)
82
{
83
$this->canFullAccess =
true
;
84
}
85
86
if
($this->canRead && $this->canWrite && $this->canFullAccess)
87
{
88
break
;
89
}
90
}
91
}
92
98
public
function
getCanRead
(): bool
99
{
100
return
$this->canRead;
101
}
102
108
public
function
getCanWrite
(): bool
109
{
110
return
$this->canWrite;
111
}
112
118
public
function
getCanFullAccess
(): bool
119
{
120
return
$this->canFullAccess;
121
}
122
128
public
function
getAccessCodes
(): array
129
{
130
return
$this->accessCodes;
131
}
132
138
public
function
getDeleteAccessCodes
(): array
139
{
140
return
$this->deleteAccessCodes;
141
}
142
}
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions
Definition
IblockCatalogPermissions.php:14
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\setRights
setRights(array $rights)
Definition
IblockCatalogPermissions.php:46
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\getCanFullAccess
getCanFullAccess()
Definition
IblockCatalogPermissions.php:118
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\getCanWrite
getCanWrite()
Definition
IblockCatalogPermissions.php:108
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\getDeleteAccessCodes
getDeleteAccessCodes()
Definition
IblockCatalogPermissions.php:138
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\getAccessCodes
getAccessCodes()
Definition
IblockCatalogPermissions.php:128
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\getCanRead
getCanRead()
Definition
IblockCatalogPermissions.php:98
Bitrix\Catalog\Access\Permission\Catalog\IblockCatalogPermissions\__construct
__construct(array $accessCodes, array $deleteAccessCodes=[])
Definition
IblockCatalogPermissions.php:31
Bitrix\Catalog\Access\Permission\PermissionDictionary
Definition
PermissionDictionary.php:21
Bitrix\Catalog\Access\Permission\PermissionDictionary\CATALOG_PRODUCT_READ
const CATALOG_PRODUCT_READ
Definition
PermissionDictionary.php:54
Bitrix\Catalog\Access\Permission\PermissionDictionary\CATALOG_PRODUCT_ADD
const CATALOG_PRODUCT_ADD
Definition
PermissionDictionary.php:55
Bitrix\Catalog\Access\Permission\PermissionDictionary\CATALOG_SETTINGS_ACCESS
const CATALOG_SETTINGS_ACCESS
Definition
PermissionDictionary.php:40
Bitrix\Catalog\Access\Permission\PermissionDictionary\CATALOG_PRODUCT_EDIT
const CATALOG_PRODUCT_EDIT
Definition
PermissionDictionary.php:56
Bitrix\Catalog\Access\Permission\PermissionDictionary\CATALOG_PRODUCT_DELETE
const CATALOG_PRODUCT_DELETE
Definition
PermissionDictionary.php:57
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Catalog\Access\Permission\Catalog
Definition
IblockCatalogPermissions.php:3
modules
catalog
lib
Access
Permission
Catalog
IblockCatalogPermissions.php
Создано системой
1.10.0