Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ShopGroupAssistant.php
1<?php
10
13
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 {
34 }
35
37 }
38
40 {
42 }
43
44 if ($controller->check( ActionDictionary::ACTION_CATALOG_READ))
45 {
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}
static getRow(array $parameters)