40 return $this->getAccessRightsWithInventoryManagement();
43 return $this->getAccessRightsGeneral();
51 private function getAccessRightsWithInventoryManagement(): array
55 $sections = $this->getSections(
true);
56 $storeDocumentsMap = $this->getStoreDocumentSectionCodesMap();
57 foreach ($sections as $sectionName => $permissions)
59 $isStoreSectionName = isset($storeDocumentsMap[$sectionName]);
61 foreach ($permissions as $permissionId)
63 if ($isStoreSectionName)
65 [$permissionId, $documentId] = explode(
'_', $permissionId);
66 $rights[] = PermissionDictionary::getStoreDocumentPermission($permissionId, $documentId);
70 $rights[] = PermissionDictionary::getPermission($permissionId);
75 'sectionCode' => $sectionName,
76 'sectionTitle' =>
Loc::getMessage(
'CATALOG_CONFIG_PERMISSIONS_' . $sectionName) ?? $sectionName,
77 'sectionHint' =>
Loc::getMessage(
'HINT_CATALOG_CONFIG_PERMISSIONS_' . $sectionName),
82 $res = $this->appendArticleLinks($res);
94 private function appendArticleLinks(array $res): array
96 $articles =
new PermissionArticles();
98 foreach ($res as $i => $info)
100 if (isset($info[
'sectionHint']))
102 $articleLink = $articles->getSectionArticleLink($info[
'sectionCode']);
105 $res[$i][
'sectionHint'] .=
" {$articleLink}";
109 foreach ($info[
'rights'] as $z => $right)
111 $permissionId = $right[
'id'];
113 if (isset($right[
'hint']))
115 $articleLink = $articles->getPermissionArticleLink($permissionId);
118 $res[$i][
'rights'][$z][
'hint'] .=
" {$articleLink}";
132 private function getAccessRightsGeneral(): array
136 $sections = $this->getSections(
false);
137 foreach ($sections as $sectionName => $permissions)
140 foreach ($permissions as $permissionId)
142 $rights[] = PermissionDictionary::getPermission($permissionId);
146 'sectionTitle' =>
Loc::getMessage(
'CATALOG_CONFIG_PERMISSIONS_' . $sectionName) ?? $sectionName,
163 $members = $this->getRoleMembersMap();
164 $accessRights = $this->getRoleAccessRightsMap();
167 foreach ($list as $row)
169 $roleId = (int) $row[
'ID'];
174 'accessRights' => $accessRights[$roleId] ?? [],
175 'members' => $members[$roleId] ?? [],
189 private function getSections(
bool $withInventoryManagmentSections): array
192 self::SECTION_CATALOG => $this->getCommonCatalogSection(),
195 if ($withInventoryManagmentSections)
197 $sections[self::SECTION_INVENTORY_MANAGMENT] = [
198 PermissionDictionary::CATALOG_INVENTORY_MANAGEMENT_ACCESS,
199 PermissionDictionary::CATALOG_STORE_MODIFY,
200 PermissionDictionary::CATALOG_STORE_VIEW,
203 if (Loader::includeModule(
'report'))
205 $sections[self::SECTION_INVENTORY_MANAGMENT][] = PermissionDictionary::CATALOG_STORE_ANALYTIC_VIEW;
207 $sections[self::SECTION_INVENTORY_MANAGMENT][] = PermissionDictionary::CATALOG_SETTINGS_STORE_DOCUMENT_CARD_EDIT;
209 foreach ($this->getStoreDocumentSectionCodesMap() as $code => $typeId)
211 $sections[$code] = $this->getStoreDocumentsSectionPermissions($typeId);
214 $reservationSection = $this->getReservationSection();
215 if ($reservationSection)
217 $sections[self::SECTION_RESERVATION] = $reservationSection;
221 $sections[self::SECTION_CATALOG_SETTINGS] = $this->getCatalogSettingsSection();
222 $sections[self::SECTION_SETTINGS] = [
223 PermissionDictionary::CATALOG_SETTINGS_ACCESS,
224 PermissionDictionary::CATALOG_SETTINGS_EDIT_RIGHTS,
225 PermissionDictionary::CATALOG_SETTINGS_SELL_NEGATIVE_COMMODITIES,
228 if ($withInventoryManagmentSections)
230 $sections[self::SECTION_RESERVATION][] = PermissionDictionary::CATALOG_RESERVE_SETTINGS;
236 private function getReservationSection(): array
240 if (Loader::includeModule(
'crm'))
242 $result[] = PermissionDictionary::CATALOG_RESERVE_DEAL;
251 private function getCommonCatalogSection(): array
254 PermissionDictionary::CATALOG_PRODUCT_READ,
255 PermissionDictionary::CATALOG_PRODUCT_PURCHASING_PRICE_VIEW,
256 PermissionDictionary::CATALOG_PRODUCT_ADD,
257 PermissionDictionary::CATALOG_PRODUCT_EDIT,
258 PermissionDictionary::CATALOG_PRODUCT_DELETE,
259 PermissionDictionary::CATALOG_PRODUCT_EDIT_CATALOG_PRICE,
260 PermissionDictionary::CATALOG_PRODUCT_EDIT_ENTITY_PRICE,
261 PermissionDictionary::CATALOG_PRODUCT_SET_DISCOUNT,
264 if (Loader::includeModule(
'bitrix24'))
266 $result[] = PermissionDictionary::CATALOG_PRODUCT_PUBLIC_VISIBILITY;
269 $result[] = PermissionDictionary::CATALOG_IMPORT_EXECUTION;
270 $result[] = PermissionDictionary::CATALOG_EXPORT_EXECUTION;
275 private function getCatalogSettingsSection(): array
278 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_EDIT,
279 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_SET_PROFILE_FOR_USERS,
280 PermissionDictionary::CATALOG_VAT_MODIFY,
281 PermissionDictionary::CATALOG_MEASURE_MODIFY,
282 PermissionDictionary::CATALOG_PRICE_GROUP_MODIFY,
283 PermissionDictionary::CATALOG_PRODUCT_PRICE_EXTRA_EDIT,
286 $onlyBox = !ModuleManager::isModuleInstalled(
'bitrix24');
289 array_push($result, ...[
290 PermissionDictionary::CATALOG_IMPORT_EDIT,
291 PermissionDictionary::CATALOG_EXPORT_EDIT,
298 private function getStoreDocumentSectionCodesMap(): array
316 private function getStoreDocumentsSectionPermissions(
string $typeId): array
319 PermissionDictionary::CATALOG_STORE_DOCUMENT_VIEW,
320 PermissionDictionary::CATALOG_STORE_DOCUMENT_MODIFY,
321 PermissionDictionary::CATALOG_STORE_DOCUMENT_CONDUCT,
322 PermissionDictionary::CATALOG_STORE_DOCUMENT_CANCEL,
323 PermissionDictionary::CATALOG_STORE_DOCUMENT_DELETE,
333 $permissions[] = PermissionDictionary::CATALOG_STORE_DOCUMENT_ALLOW_NEGATION_PRODUCT_QUANTITY;
337 foreach ($permissions as $permission)
339 $result[] =
"{$permission}_{$typeId}";
350 private function getRoleMembersMap(): array
352 return (
new RoleMembersInfo)->getMemberInfos();
360 private function getRoleAccessRightsMap(): array
364 $rows = PermissionTable::getList([
371 foreach ($rows as $row)
373 $roleId = $row[
'ROLE_ID'];
375 $result[$roleId][] = [
376 'id' => $row[
'PERMISSION_ID'],
377 'value' => $row[
'VALUE']
393 $sections = $this->getSections(
false);
394 $sectionsWithInventoryManagment = $this->getSections(
true);
396 foreach ($sectionsWithInventoryManagment as $code => $permissions)
398 $generalPermissions = $sections[$code] ??
null;
399 if (!isset($generalPermissions))
401 array_push($result, ... $permissions);
406 foreach ($permissions as $permissionId)
408 if (!in_array($permissionId, $generalPermissions,
true))
410 $result[] = $permissionId;