1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ShopGroupAssistant.php
См. документацию.
1<?php
8
9namespace Bitrix\Catalog\Access;
10
11use Bitrix\Catalog\Config\Feature;
12use Bitrix\Main\GroupTable;
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 {
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
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 $groupId = \CGroup::GetIDByCode($groupCode);
72 if (!$groupId)
73 {
74 return false;
75 }
76
77 \CUser::appendUserGroup($userId, [$groupId]);
78
79 return true;
80 }
81}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static GetIDByCode($code)
Определения group.php:1502