Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
RoleMembersInfo.php
1<?php
2
4
9
14{
20 public function getMemberInfos(): array
21 {
22 $result = [];
23
24 $rows = RoleRelationTable::getList([
25 'select' => [
26 'ROLE_ID',
27 'RELATION',
28 ],
29 ]);
30 foreach ($rows as $row)
31 {
32 $roleId = $row['ROLE_ID'];
33 $accessCode = $row['RELATION'];
34
35 $result[$roleId][$accessCode] = true;
36 }
37
38 $result = $this->fillMembersInfo($result);
39
40 return $result;
41 }
42
50 private function fillMembersInfo(array $rolesAccessCodes): array
51 {
52 $this->preloadProviderUserModels($rolesAccessCodes);
53
54 $provider = new DataProvider();
55 foreach ($rolesAccessCodes as $roleId => $accessCodes)
56 {
57 foreach ($accessCodes as $accessCode => $value)
58 {
59 $accessCodeObject = new AccessCode($accessCode);
60 $entity = $provider->getEntity(
61 $accessCodeObject->getEntityType(),
62 $accessCodeObject->getEntityId()
63 );
64
65 $rolesAccessCodes[$roleId][$accessCode] = $entity->getMetaData();
66 }
67 }
68
69 return $rolesAccessCodes;
70 }
71
79 private function preloadProviderUserModels(array $rolesAccessCodes): void
80 {
81 $userIds = [];
82
83 foreach ($rolesAccessCodes as $accessCodes)
84 {
85 foreach ($accessCodes as $accessCode => $value)
86 {
87 $accessCodeObject = new AccessCode($accessCode);
88 if ($accessCodeObject->getEntityType() === AccessCode::TYPE_USER)
89 {
90 $userIds[] = $accessCodeObject->getEntityId();
91 }
92 }
93 }
94
95 if ($userIds)
96 {
98 '=ID' => $userIds,
99 ]);
100 }
101 }
102}
static preLoadModels(array $filter)
Definition user.php:133