Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ShopGroupAssistant.php
1
<?php
9
namespace
Bitrix\Catalog\Access
;
10
11
use
Bitrix\Catalog\Config\Feature
;
12
use
Bitrix\Main\GroupTable
;
13
14
class
ShopGroupAssistant
15
{
16
public
const
SHOP_ADMIN_USER_GROUP_CODE
=
'CRM_SHOP_ADMIN'
;
17
public
const
SHOP_MANAGER_USER_GROUP_CODE
=
'CRM_SHOP_MANAGER'
;
18
24
public
static
function
getShopUserGroupCode(
int
$userId): ?string
25
{
27
$controller =
AccessController::getInstance
($userId);
28
29
if
(!Feature::isAccessControllerCheckingEnabled())
30
{
31
if
($controller->isAdmin())
32
{
33
return
self::SHOP_ADMIN_USER_GROUP_CODE
;
34
}
35
36
return
self::SHOP_MANAGER_USER_GROUP_CODE
;
37
}
38
39
if
($controller->check(
ActionDictionary::ACTION_CATALOG_SETTINGS_ACCESS
))
40
{
41
return
self::SHOP_ADMIN_USER_GROUP_CODE
;
42
}
43
44
if
($controller->check(
ActionDictionary::ACTION_CATALOG_READ
))
45
{
46
return
self::SHOP_MANAGER_USER_GROUP_CODE
;
47
}
48
49
return
null
;
50
}
51
63
public
static
function
addShopAccess
($userId): bool
64
{
65
$groupCode = self::getShopUserGroupCode($userId);
66
if
(!$groupCode)
67
{
68
return
false
;
69
}
70
71
$group =
GroupTable::getRow
([
72
'filter'
=> [
'=STRING_ID'
=> $groupCode],
73
'select'
=> [
'ID'
],
74
]);
75
76
if
(!$group)
77
{
78
return
false
;
79
}
80
81
\CUser::appendUserGroup($userId, [$group[
'ID'
]]);
82
83
return
true
;
84
}
85
}
Bitrix\Catalog\Access\ActionDictionary\ACTION_CATALOG_READ
const ACTION_CATALOG_READ
Definition
ActionDictionary.php:23
Bitrix\Catalog\Access\ActionDictionary\ACTION_CATALOG_SETTINGS_ACCESS
const ACTION_CATALOG_SETTINGS_ACCESS
Definition
ActionDictionary.php:49
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\Catalog\Access\ShopGroupAssistant\addShopAccess
static addShopAccess($userId)
Definition
ShopGroupAssistant.php:63
Bitrix\Catalog\Config\Feature
Definition
feature.php:16
Bitrix\Main\Access\BaseAccessController\getInstance
static getInstance($userId)
Definition
baseaccesscontroller.php:38
Bitrix\Main\GroupTable
Definition
group.php:29
Bitrix\Main\ORM\Data\DataManager\getRow
static getRow(array $parameters)
Definition
datamanager.php:410
Bitrix\Catalog\Access
Definition
AccessController.php:9
modules
catalog
lib
Access
ShopGroupAssistant.php
Создано системой
1.10.0