42 if (State::isUsedInventoryManagement())
46 return $this->getAccessRightsWithInventoryManagement();
50 return $this->getAccessRightsWithExternalCatalog();
54 if (State::isExternalCatalog())
59 return $this->getAccessRightsGeneral();
67 private function getAccessRightsWithInventoryManagement():
array
71 $sections = $this->getSections(
true);
72 $storeDocumentsMap = $this->getStoreDocumentSectionCodesMap();
73 foreach ($sections as $sectionName => $permissions)
75 $isStoreSectionName = isset($storeDocumentsMap[$sectionName]);
77 foreach ($permissions as $permissionId)
79 if ($isStoreSectionName)
81 [$permissionId, $documentId] = explode(
'_', $permissionId);
82 $rights[] = PermissionDictionary::getStoreDocumentPermission($permissionId, $documentId);
86 $rights[] = PermissionDictionary::getPermission($permissionId);
91 'sectionCode' => $sectionName,
92 'sectionTitle' => Loc::getMessage(
'CATALOG_CONFIG_PERMISSIONS_' . $sectionName) ?? $sectionName,
93 'sectionHint' => Loc::getMessage(
'HINT_CATALOG_CONFIG_PERMISSIONS_' . $sectionName),
98 $res = $this->appendArticleLinks(
$res);
108 private function getAccessRightsWithExternalCatalog():
array
112 $sections = $this->getSectionsForExternalCatalog();
113 $realizationSection = [
116 foreach ($sections as $sectionName => $permissions)
118 $isStoreSectionName = isset($realizationSection[$sectionName]);
120 foreach ($permissions as $permissionId)
122 if ($isStoreSectionName)
124 [$permissionId, $documentId] = explode(
'_', $permissionId);
125 $rights[] = PermissionDictionary::getStoreDocumentPermission($permissionId, $documentId);
129 $rights[] = PermissionDictionary::getPermission($permissionId);
134 'sectionCode' => $sectionName,
135 'sectionTitle' => Loc::getMessage(
'CATALOG_CONFIG_PERMISSIONS_' . $sectionName) ?? $sectionName,
136 'sectionHint' => Loc::getMessage(
'HINT_CATALOG_CONFIG_PERMISSIONS_' . $sectionName),
141 $res = $this->appendArticleLinks(
$res);
155 $articles =
new PermissionArticles();
159 if (isset(
$info[
'sectionHint']))
161 $articleLink = $articles->getSectionArticleLink(
$info[
'sectionCode']);
164 $res[
$i][
'sectionHint'] .=
" {$articleLink}";
170 $permissionId =
$right[
'id'];
172 if (isset(
$right[
'hint']))
174 $articleLink = $articles->getPermissionArticleLink($permissionId);
177 $res[
$i][
'rights'][
$z][
'hint'] .=
" {$articleLink}";
191 private function getAccessRightsGeneral():
array
195 $sections = $this->getSections(
false);
196 foreach ($sections as $sectionName => $permissions)
199 foreach ($permissions as $permissionId)
201 $rights[] = PermissionDictionary::getPermission($permissionId);
205 'sectionTitle' => Loc::getMessage(
'CATALOG_CONFIG_PERMISSIONS_' . $sectionName) ?? $sectionName,
222 $members = $this->getRoleMembersMap();
223 $accessRights = $this->getRoleAccessRightsMap();
226 foreach ($list as $row)
228 $roleId = (int) $row[
'ID'];
233 'accessRights' => $accessRights[$roleId] ?? [],
234 'members' => $members[$roleId] ?? [],
248 private function getSections(
bool $withInventoryManagmentSections):
array
251 self::SECTION_CATALOG => $this->getCommonCatalogSection(),
254 if ($withInventoryManagmentSections)
256 $sections[self::SECTION_INVENTORY_MANAGMENT] = [
257 PermissionDictionary::CATALOG_INVENTORY_MANAGEMENT_ACCESS,
258 PermissionDictionary::CATALOG_STORE_MODIFY,
259 PermissionDictionary::CATALOG_STORE_VIEW,
262 if (Loader::includeModule(
'report'))
264 $sections[self::SECTION_INVENTORY_MANAGMENT][] = PermissionDictionary::CATALOG_STORE_ANALYTIC_VIEW;
266 $sections[self::SECTION_INVENTORY_MANAGMENT][] = PermissionDictionary::CATALOG_SETTINGS_STORE_DOCUMENT_CARD_EDIT;
268 foreach ($this->getStoreDocumentSectionCodesMap() as
$code => $typeId)
270 $sections[
$code] = $this->getStoreDocumentsSectionPermissions($typeId);
273 $reservationSection = $this->getReservationSection();
274 if ($reservationSection)
276 $sections[self::SECTION_RESERVATION] = $reservationSection;
280 $sections[self::SECTION_CATALOG_SETTINGS] = $this->getCatalogSettingsSection();
281 $sections[self::SECTION_SETTINGS] = [
282 PermissionDictionary::CATALOG_SETTINGS_ACCESS,
283 PermissionDictionary::CATALOG_SETTINGS_EDIT_RIGHTS,
284 PermissionDictionary::CATALOG_SETTINGS_SELL_NEGATIVE_COMMODITIES,
287 if ($withInventoryManagmentSections)
289 $sections[self::SECTION_RESERVATION][] = PermissionDictionary::CATALOG_RESERVE_SETTINGS;
295 private function getSectionsForExternalCatalog():
array
298 self::SECTION_CATALOG => $this->getCommonCatalogSectionForExternalCatalog(),
301 $sections[self::SECTION_INVENTORY_MANAGMENT] = [
302 PermissionDictionary::CATALOG_STORE_VIEW,
305 $sections[self::SECTION_INVENTORY_MANAGMENT][] = PermissionDictionary::CATALOG_SETTINGS_STORE_DOCUMENT_CARD_EDIT;
309 $reservationSection = $this->getReservationSection();
310 if ($reservationSection)
312 $sections[self::SECTION_RESERVATION] = $reservationSection;
315 $sections[self::SECTION_CATALOG_SETTINGS] = $this->getCatalogSettingsSectionForExternalCatalog();
316 $sections[self::SECTION_SETTINGS] = [
317 PermissionDictionary::CATALOG_SETTINGS_ACCESS,
318 PermissionDictionary::CATALOG_SETTINGS_EDIT_RIGHTS,
319 PermissionDictionary::CATALOG_SETTINGS_SELL_NEGATIVE_COMMODITIES,
322 $sections[self::SECTION_RESERVATION][] = PermissionDictionary::CATALOG_RESERVE_SETTINGS;
327 private function getReservationSection():
array
331 if (Loader::includeModule(
'crm'))
333 $result[] = PermissionDictionary::CATALOG_RESERVE_DEAL;
342 private function getCommonCatalogSection():
array
345 PermissionDictionary::CATALOG_PRODUCT_READ,
346 PermissionDictionary::CATALOG_PRODUCT_PURCHASING_PRICE_VIEW,
347 PermissionDictionary::CATALOG_PRODUCT_ADD,
348 PermissionDictionary::CATALOG_PRODUCT_EDIT,
349 PermissionDictionary::CATALOG_PRODUCT_DELETE,
350 PermissionDictionary::CATALOG_PRODUCT_EDIT_CATALOG_PRICE,
351 PermissionDictionary::CATALOG_PRODUCT_EDIT_ENTITY_PRICE,
352 PermissionDictionary::CATALOG_PRODUCT_SET_DISCOUNT,
355 if (Loader::includeModule(
'bitrix24'))
357 $result[] = PermissionDictionary::CATALOG_PRODUCT_PUBLIC_VISIBILITY;
360 $result[] = PermissionDictionary::CATALOG_IMPORT_EXECUTION;
361 $result[] = PermissionDictionary::CATALOG_EXPORT_EXECUTION;
366 private function getCommonCatalogSectionForExternalCatalog():
array
369 PermissionDictionary::CATALOG_PRODUCT_PURCHASING_PRICE_VIEW,
370 PermissionDictionary::CATALOG_PRODUCT_EDIT_ENTITY_PRICE,
371 PermissionDictionary::CATALOG_PRODUCT_SET_DISCOUNT,
375 private function getCatalogSettingsSection():
array
378 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_EDIT,
379 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_SET_PROFILE_FOR_USERS,
380 PermissionDictionary::CATALOG_VAT_MODIFY,
381 PermissionDictionary::CATALOG_MEASURE_MODIFY,
382 PermissionDictionary::CATALOG_PRICE_GROUP_MODIFY,
383 PermissionDictionary::CATALOG_PRODUCT_PRICE_EXTRA_EDIT,
386 $onlyBox = !ModuleManager::isModuleInstalled(
'bitrix24');
390 PermissionDictionary::CATALOG_IMPORT_EDIT,
391 PermissionDictionary::CATALOG_EXPORT_EDIT,
398 private function getCatalogSettingsSectionForExternalCatalog():
array
401 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_EDIT,
402 PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_SET_PROFILE_FOR_USERS,
406 private function getStoreDocumentSectionCodesMap():
array
424 private function getStoreDocumentsSectionPermissions(
string $typeId):
array
429 PermissionDictionary::CATALOG_STORE_DOCUMENT_VIEW,
430 PermissionDictionary::CATALOG_STORE_DOCUMENT_MODIFY,
431 PermissionDictionary::CATALOG_STORE_DOCUMENT_CONDUCT,
432 PermissionDictionary::CATALOG_STORE_DOCUMENT_DELETE,
438 PermissionDictionary::CATALOG_STORE_DOCUMENT_VIEW,
439 PermissionDictionary::CATALOG_STORE_DOCUMENT_MODIFY,
440 PermissionDictionary::CATALOG_STORE_DOCUMENT_CONDUCT,
441 PermissionDictionary::CATALOG_STORE_DOCUMENT_CANCEL,
442 PermissionDictionary::CATALOG_STORE_DOCUMENT_DELETE,
451 if (in_array($typeId, $typesWithNag,
true) && !State::isProductBatchMethodSelected())
453 $permissions[] = PermissionDictionary::CATALOG_STORE_DOCUMENT_ALLOW_NEGATION_PRODUCT_QUANTITY;
457 foreach ($permissions as $permission)
459 $result[] =
"{$permission}_{$typeId}";
470 private function getRoleMembersMap():
array
480 private function getRoleAccessRightsMap():
array
491 foreach (
$rows as $row)
493 $roleId = $row[
'ROLE_ID'];
496 'id' => $row[
'PERMISSION_ID'],
497 'value' => $row[
'VALUE']
513 $sections = $this->getSections(
false);
514 $sectionsWithInventoryManagment = $this->getSections(
true);
516 foreach ($sectionsWithInventoryManagment as
$code => $permissions)
518 $generalPermissions = $sections[
$code] ??
null;
519 if (!isset($generalPermissions))
521 array_push(
$result, ... $permissions);
526 foreach ($permissions as $permissionId)
528 if (!in_array($permissionId, $generalPermissions,
true))