Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
BaseIblockRule.php
1
<?php
2
3
namespace
Bitrix\Catalog\Access\IblockRule
;
4
5
use
Bitrix\Catalog\Access\ShopGroupAssistant
;
6
use
Bitrix\Main\Access\AccessibleItem
;
7
use
Bitrix\Main\Access\Rule\AbstractRule
;
8
use
Bitrix\Catalog\Access\AccessController
;
9
use
Bitrix\Catalog\Access\Model\UserModel
;
10
use
Bitrix\Main\GroupTable
;
11
12
class
BaseIblockRule
extends
AbstractRule
13
{
14
/* @var AccessController $controller */
15
/* @var UserModel $user */
16
24
public
function
execute
(
AccessibleItem
$item =
null
, $params =
null
): bool
25
{
26
if
($this->user->isAdmin())
27
{
28
return
true
;
29
}
30
31
return
$this->
check
($params);
32
}
33
41
protected
function
check
($params): bool
42
{
43
$groups = $this->user->getRightGroups();
44
45
$groupData =
GroupTable::getList
([
46
'filter'
=> [
'STRING_ID'
=> $this->
getShopIblockTypes
()],
47
'select'
=> [
'ID'
]
48
])
49
->fetchAll()
50
;
51
52
$shopGroupIds = array_column($groupData,
'ID'
);
53
if
(!$shopGroupIds)
54
{
55
return
false
;
56
}
57
58
return
!empty(array_intersect($groups, $shopGroupIds));
59
}
60
64
protected
function
getShopIblockTypes
(): array
65
{
66
return
[
ShopGroupAssistant::SHOP_ADMIN_USER_GROUP_CODE
,
ShopGroupAssistant::SHOP_MANAGER_USER_GROUP_CODE
];
67
}
68
}
Bitrix\Catalog\Access\AccessController
Definition
AccessController.php:28
Bitrix\Catalog\Access\IblockRule\BaseIblockRule
Definition
BaseIblockRule.php:13
Bitrix\Catalog\Access\IblockRule\BaseIblockRule\execute
execute(AccessibleItem $item=null, $params=null)
Definition
BaseIblockRule.php:24
Bitrix\Catalog\Access\IblockRule\BaseIblockRule\getShopIblockTypes
getShopIblockTypes()
Definition
BaseIblockRule.php:64
Bitrix\Catalog\Access\IblockRule\BaseIblockRule\check
check($params)
Definition
BaseIblockRule.php:41
Bitrix\Catalog\Access\Model\UserModel
Definition
UserModel.php:18
Bitrix\Catalog\Access\ShopGroupAssistant
Definition
ShopGroupAssistant.php:15
Bitrix\Catalog\Access\ShopGroupAssistant\SHOP_ADMIN_USER_GROUP_CODE
const SHOP_ADMIN_USER_GROUP_CODE
Definition
ShopGroupAssistant.php:16
Bitrix\Catalog\Access\ShopGroupAssistant\SHOP_MANAGER_USER_GROUP_CODE
const SHOP_MANAGER_USER_GROUP_CODE
Definition
ShopGroupAssistant.php:17
Bitrix\Main\Access\Rule\AbstractRule
Definition
abstractrule.php:16
Bitrix\Main\GroupTable
Definition
group.php:29
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Main\Access\AccessibleItem
Definition
accessibleitem.php:13
Bitrix\Catalog\Access\IblockRule
Definition
BaseIblockRule.php:3
modules
catalog
lib
Access
IblockRule
BaseIblockRule.php
Создано системой
1.10.0