Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IblockCatalogPermissionStepper.php
1<?php
2
4
9
20{
21 private const PORTION = 100;
22
23 protected static $moduleId = 'catalog';
24
25 public function execute(array &$option): bool
26 {
27 if (!Loader::includeModule('iblock'))
28 {
30 }
31
32 $emptyDepartmentTypeFirst = serialize([]);
33 $emptyDepartmentTypeSecond = serialize([0]);
34 $externalTypes = UserTable::getExternalUserTypes();
35 $externalTypes[] = null;
36 $filter = [
37 '!=UF_DEPARTMENT' => [null, $emptyDepartmentTypeFirst, $emptyDepartmentTypeSecond],
38 '!=EXTERNAL_AUTH_ID' => $externalTypes,
39 ];
40
41 if (isset($option['lastId']))
42 {
43 $filter['>ID'] = (int)$option['lastId'];
44 }
45
46 $userData = UserTable::getList([
47 'filter' => $filter,
48 'select' => ['ID'],
49 'limit' => self::PORTION,
50 ])
51 ->fetchAll()
52 ;
53
54 $userIds = array_column($userData, 'ID');
55 if ($userIds)
56 {
57 $this->updateIblockAccess($userIds);
58 if (count($userIds) === self::PORTION)
59 {
60 $option['lastId'] = array_pop($userIds);
61
63 }
64 }
65
67 }
68
69 private function updateIblockAccess(array $userIds): void
70 {
71 $userGroupMap = [
74 ];
75
76 foreach ($userIds as $userId)
77 {
78 $groupCode = ShopGroupAssistant::getShopUserGroupCode($userId);
79 if ($groupCode && isset($userGroupMap[$groupCode]))
80 {
81 $userGroupMap[$groupCode][] = $userId;
82 }
83 }
84
85 foreach ($userGroupMap as $groupCode => $groupUserIds)
86 {
88 $groupUserIds,
89 $userIds,
90 $groupCode
91 );
92 }
93 }
94}
static updateShopAccessGroup(array $userIds, array $allUserIds, string $groupType)