Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ActionDictionary.php
1<?php
10
13
14Loc::loadMessages(__FILE__);
15
17{
18 public const PREFIX = "ACTION_";
19
23 public const ACTION_CATALOG_READ = 'catalog_read';
28 public const ACTION_CATALOG_VIEW = 'catalog_view';
29 public const ACTION_STORE_VIEW = 'catalog_store';
30 public const ACTION_STORE_ANALYTIC_VIEW = 'catalog_store_analytic';
31 public const ACTION_VAT_EDIT = 'catalog_vat';
32 public const ACTION_MEASURE_EDIT = 'catalog_measure';
33 public const ACTION_CATALOG_IMPORT_EDIT = 'catalog_import_edit';
34 public const ACTION_CATALOG_EXPORT_EDIT = 'catalog_export_edit';
35 public const ACTION_CATALOG_IMPORT_EXECUTION = 'catalog_import_exec';
36 public const ACTION_CATALOG_EXPORT_EXECUTION = 'catalog_export_exec';
37 public const ACTION_INVENTORY_MANAGEMENT_ACCESS = 'catalog_inventory_management_access';
38 public const ACTION_STORE_MODIFY = 'catalog_store_modify';
39 public const ACTION_DEAL_PRODUCT_RESERVE = 'catalog_deal_product_reserve';
40 public const ACTION_STORE_PRODUCT_RESERVE = 'catalog_store_product_reserve';
41 public const ACTION_RESERVED_SETTINGS_ACCESS = 'catalog_setting_access';
42 public const ACTION_STORE_DOCUMENT_VIEW = 'catalog_store_document_view';
43 public const ACTION_STORE_DOCUMENT_PERFORM = 'catalog_store_document_perform';
44 public const ACTION_STORE_DOCUMENT_MODIFY = 'catalog_store_document_modify';
45 public const ACTION_STORE_DOCUMENT_CANCEL = 'catalog_store_document_cancel';
46 public const ACTION_STORE_DOCUMENT_CONDUCT = 'catalog_store_document_conduct';
47 public const ACTION_STORE_DOCUMENT_DELETE = 'catalog_store_document_delete';
48 public const ACTION_STORE_DOCUMENT_ALLOW_NEGATION_PRODUCT_QUANTITY = 'catalog_store_document_allow_negation_product_quantity';
49 public const ACTION_CATALOG_SETTINGS_ACCESS = 'catalog_settings';
50 public const ACTION_CATALOG_RIGHTS_EDIT = 'catalog_rights_edit';
51 public const ACTION_SELL_NEGATIVE_COMMODITIES_SETTINGS_EDIT = 'catalog_sell_negative_commodities_settings_edit';
52 public const ACTION_PRODUCT_CARD_EDIT = 'catalog_product_card_edit';
53 public const ACTION_PRODUCT_CARD_SETTINGS_FOR_USERS_SET = 'catalog_product_card_settings_for_users_set';
54 public const ACTION_STORE_DOCUMENT_CARD_EDIT = 'catalog_document_card_edit';
58 public const ACTION_PRODUCT_VIEW = 'catalog_product_view';
59 public const ACTION_PRODUCT_ADD = 'catalog_product_add';
60 public const ACTION_PRODUCT_EDIT = 'catalog_product_edit';
61 public const ACTION_PRODUCT_DELETE = 'catalog_product_delete';
62 public const ACTION_PRODUCT_PURCHASE_INFO_VIEW = 'catalog_purchas_info';
63 public const ACTION_PRODUCT_DISCOUNT_SET = 'catalog_discount';
64 public const ACTION_PRODUCT_PRICE_EXTRA_EDIT = 'catalog_extra';
65 public const ACTION_PRICE_GROUP_EDIT = 'catalog_group';
66 public const ACTION_PRICE_EDIT = 'catalog_price';
67 public const ACTION_PRICE_ENTITY_EDIT = 'catalog_entity_price';
68 public const ACTION_PRODUCT_PUBLIC_VISIBILITY_SET = 'catalog_product_public_visibility_set';
69
70 protected static function getClassName()
71 {
72 return __CLASS__;
73 }
74
79 public static function getActionPermissionMap(): array
80 {
81 return [
82 self::ACTION_CATALOG_VIEW => PermissionDictionary::CATALOG_PRODUCT_VIEW,
83 self::ACTION_CATALOG_READ => PermissionDictionary::CATALOG_PRODUCT_READ,
84 self::ACTION_VAT_EDIT => PermissionDictionary::CATALOG_VAT_MODIFY,
85 self::ACTION_CATALOG_IMPORT_EDIT => PermissionDictionary::CATALOG_IMPORT_EDIT,
86 self::ACTION_CATALOG_EXPORT_EDIT => PermissionDictionary::CATALOG_EXPORT_EDIT,
87 self::ACTION_CATALOG_EXPORT_EXECUTION => PermissionDictionary::CATALOG_EXPORT_EXECUTION,
88 self::ACTION_CATALOG_IMPORT_EXECUTION => PermissionDictionary::CATALOG_IMPORT_EXECUTION,
89 self::ACTION_PRODUCT_PURCHASE_INFO_VIEW => PermissionDictionary::CATALOG_PRODUCT_PURCHASING_PRICE_VIEW,
90 self::ACTION_PRODUCT_PRICE_EXTRA_EDIT => PermissionDictionary::CATALOG_PRODUCT_PRICE_EXTRA_EDIT,
91 self::ACTION_MEASURE_EDIT => PermissionDictionary::CATALOG_MEASURE_MODIFY,
92 self::ACTION_STORE_VIEW => PermissionDictionary::CATALOG_STORE_VIEW,
93 self::ACTION_STORE_ANALYTIC_VIEW => PermissionDictionary::CATALOG_STORE_ANALYTIC_VIEW,
94 self::ACTION_INVENTORY_MANAGEMENT_ACCESS => PermissionDictionary::CATALOG_INVENTORY_MANAGEMENT_ACCESS,
95 self::ACTION_STORE_MODIFY => PermissionDictionary::CATALOG_STORE_MODIFY,
96 self::ACTION_DEAL_PRODUCT_RESERVE => PermissionDictionary::CATALOG_RESERVE_DEAL,
97 self::ACTION_STORE_PRODUCT_RESERVE => PermissionDictionary::CATALOG_STORE_RESERVE,
98 self::ACTION_RESERVED_SETTINGS_ACCESS => PermissionDictionary::CATALOG_RESERVE_SETTINGS,
99 self::ACTION_STORE_DOCUMENT_VIEW => PermissionDictionary::CATALOG_STORE_DOCUMENT,
100 self::ACTION_STORE_DOCUMENT_MODIFY => PermissionDictionary::CATALOG_STORE_DOCUMENT,
101 self::ACTION_STORE_DOCUMENT_CANCEL => PermissionDictionary::CATALOG_STORE_DOCUMENT,
102 self::ACTION_STORE_DOCUMENT_CONDUCT => PermissionDictionary::CATALOG_STORE_DOCUMENT,
103 self::ACTION_STORE_DOCUMENT_DELETE => PermissionDictionary::CATALOG_STORE_DOCUMENT,
104 self::ACTION_CATALOG_SETTINGS_ACCESS => PermissionDictionary::CATALOG_SETTINGS_ACCESS,
105 self::ACTION_CATALOG_RIGHTS_EDIT => PermissionDictionary::CATALOG_SETTINGS_EDIT_RIGHTS,
106 self::ACTION_SELL_NEGATIVE_COMMODITIES_SETTINGS_EDIT => PermissionDictionary::CATALOG_SETTINGS_SELL_NEGATIVE_COMMODITIES,
107 self::ACTION_PRODUCT_CARD_EDIT => PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_EDIT,
108 self::ACTION_PRODUCT_CARD_SETTINGS_FOR_USERS_SET => PermissionDictionary::CATALOG_SETTINGS_PRODUCT_CARD_SET_PROFILE_FOR_USERS,
109 self::ACTION_STORE_DOCUMENT_CARD_EDIT => PermissionDictionary::CATALOG_SETTINGS_STORE_DOCUMENT_CARD_EDIT,
110 self::ACTION_PRODUCT_VIEW => PermissionDictionary::CATALOG_PRODUCT_VIEW,
111 self::ACTION_PRODUCT_ADD => PermissionDictionary::CATALOG_PRODUCT_ADD,
112 self::ACTION_PRODUCT_EDIT => PermissionDictionary::CATALOG_PRODUCT_EDIT,
113 self::ACTION_PRODUCT_DELETE => PermissionDictionary::CATALOG_PRODUCT_DELETE,
114 self::ACTION_PRICE_GROUP_EDIT => PermissionDictionary::CATALOG_PRICE_GROUP_MODIFY,
115 self::ACTION_PRICE_EDIT => PermissionDictionary::CATALOG_PRODUCT_EDIT_CATALOG_PRICE,
116 self::ACTION_PRICE_ENTITY_EDIT => PermissionDictionary::CATALOG_PRODUCT_EDIT_ENTITY_PRICE,
117 self::ACTION_PRODUCT_DISCOUNT_SET => PermissionDictionary::CATALOG_PRODUCT_SET_DISCOUNT,
118 self::ACTION_PRODUCT_PUBLIC_VISIBILITY_SET => PermissionDictionary::CATALOG_PRODUCT_PUBLIC_VISIBILITY,
119 ];
120 }
121
122 public static function getLegacyMap(): array
123 {
124 return [
125 self::ACTION_CATALOG_VIEW => [
128 ],
129 self::ACTION_CATALOG_READ => [self::ACTION_CATALOG_READ],
130 self::ACTION_MEASURE_EDIT => [self::ACTION_MEASURE_EDIT],
131 self::ACTION_VAT_EDIT => [self::ACTION_VAT_EDIT],
132 self::ACTION_CATALOG_IMPORT_EDIT => [self::ACTION_CATALOG_IMPORT_EDIT],
133 self::ACTION_CATALOG_EXPORT_EDIT => [self::ACTION_CATALOG_EXPORT_EDIT],
134 self::ACTION_CATALOG_EXPORT_EXECUTION => [self::ACTION_CATALOG_EXPORT_EXECUTION],
135 self::ACTION_CATALOG_IMPORT_EXECUTION => [self::ACTION_CATALOG_IMPORT_EXECUTION],
136 self::ACTION_STORE_VIEW => [
150 ],
151 self::ACTION_PRICE_GROUP_EDIT => [self::ACTION_PRICE_GROUP_EDIT],
152 self::ACTION_PRICE_EDIT => [
154 // for legacy `catalog_price` is equals modify rights
159 ],
160 self::ACTION_PRODUCT_DISCOUNT_SET => [self::ACTION_PRODUCT_DISCOUNT_SET],
161 self::ACTION_PRODUCT_PURCHASE_INFO_VIEW => [self::ACTION_PRODUCT_PURCHASE_INFO_VIEW],
162 self::ACTION_PRODUCT_PRICE_EXTRA_EDIT => [self::ACTION_PRODUCT_PRICE_EXTRA_EDIT],
163 self::ACTION_CATALOG_SETTINGS_ACCESS => [
169 ],
170 ];
171 }
172
173 public static function getStoreDocumentActionPermissionMap(): array
174 {
175 return [
176 self::ACTION_STORE_DOCUMENT_VIEW => PermissionDictionary::CATALOG_STORE_DOCUMENT_VIEW,
177 self::ACTION_STORE_DOCUMENT_MODIFY => PermissionDictionary::CATALOG_STORE_DOCUMENT_MODIFY,
178 self::ACTION_STORE_DOCUMENT_CANCEL => PermissionDictionary::CATALOG_STORE_DOCUMENT_CANCEL,
179 self::ACTION_STORE_DOCUMENT_CONDUCT => PermissionDictionary::CATALOG_STORE_DOCUMENT_CONDUCT,
180 self::ACTION_STORE_DOCUMENT_DELETE => PermissionDictionary::CATALOG_STORE_DOCUMENT_DELETE,
181 ];
182 }
183
191 public static function getActionRuleName(string $value): ?string
192 {
193 $constants = self::getActionNames();
194 if (!array_key_exists($value, $constants))
195 {
196 return null;
197 }
198
199 $storeDocumentActions = [
205 ];
206 if (in_array($value, $storeDocumentActions, true))
207 {
209 }
210
211 $storeActions = [
214 ];
215 if (in_array($value, $storeActions, true))
216 {
218 }
219
220 if ($value === self::ACTION_PRODUCT_DISCOUNT_SET)
221 {
223 }
224
225 return str_replace(self::PREFIX, '', $constants[$value]);
226 }
227
232 private static function getActionNames(): array
233 {
234 $class = new \ReflectionClass(__CLASS__);
235 $constants = $class->getConstants();
236 foreach ($constants as $name => $value)
237 {
238 if (mb_strpos($name, self::PREFIX) !== 0)
239 {
240 unset($constants[$name]);
241 }
242 }
243
244 return array_flip($constants);
245 }
246}
static loadMessages($file)
Definition loc.php:64