1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
StoreDocumentFilter.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Access\Filter;
4
5use Bitrix\Catalog\Access\Permission\PermissionDictionary;
6use Bitrix\Catalog\StoreDocumentElementTable;
7use Bitrix\Catalog\StoreDocumentTable;
8use Bitrix\Main\Access\Filter\AbstractAccessFilter;
9use Bitrix\Main\Access\Filter\UnknownEntityException;
10use Bitrix\Main\Loader;
11use Bitrix\Main\SystemException;
12use Bitrix\Sale\Internals\ShipmentItemTable;
13use Bitrix\Sale\Internals\ShipmentTable;
14
21{
25 public function getFilter(string $entity, array $params = []): array
26 {
27 $action = (string)($params['action'] ?? '');
28 if (empty($action))
29 {
30 throw new SystemException('No action is set in the parameters');
31 }
32
33 Loader::includeModule('sale');
34
35 $this->validateEntity($entity);
36
37 if ($this->user->isAdmin())
38 {
39 return [];
40 }
41
42 if ($entity === StoreDocumentTable::class)
43 {
44 return $this->getDocumentFilter($action);
45 }
46
47 if ($entity === StoreDocumentElementTable::class)
48 {
49 return $this->getElementFilter($action);
50 }
51
52 if ($entity === ShipmentTable::class)
53 {
54 return $this->getShipmentFilter($action);
55 }
56
57 if ($entity === ShipmentItemTable::class)
58 {
59 return $this->getShipmentItemFilter($action);
60 }
61 }
62
71 private function validateEntity(string $entity): void
72 {
73 $available = [
74 StoreDocumentTable::class,
75 StoreDocumentElementTable::class,
76 ShipmentTable::class,
77 ShipmentItemTable::class,
78 ];
79
80 if (!in_array($entity, $available, true))
81 {
82 throw new UnknownEntityException($entity, $this);
83 }
84 }
85
93 private function getDocumentFilter(string $action): ?array
94 {
95 $types = array_filter(
96 PermissionDictionary::getAvailableStoreDocuments(),
97 fn(string $docType) => $this->controller->check($action, null, ['value' => $docType])
98 );
99
100 if (empty($types))
101 {
102 return [
103 '=ID' => null,
104 ];
105 }
106
107 return [
108 '=DOC_TYPE' => $types,
109 ];
110 }
111
119 private function getElementFilter(string $action): ?array
120 {
121 $types = array_filter(
122 PermissionDictionary::getAvailableStoreDocuments(),
123 fn(string $docType) => $this->controller->check($action, null, ['value' => $docType])
124 );
125
126 if (empty($types))
127 {
128 return [
129 '=ID' => null,
130 ];
131 }
132
133 return [
134 '=DOCUMENT.DOC_TYPE' => $types,
135 ];
136 }
137
145 private function getShipmentFilter(string $action): ?array
146 {
147 $can = $this->controller->check($action, null, ['value' => StoreDocumentTable::TYPE_SALES_ORDERS]);
148 if (!$can)
149 {
150 return [
151 '=ID' => null,
152 ];
153 }
154
155 return [];
156 }
157
165 private function getShipmentItemFilter(string $action): ?array
166 {
167 // identical checks
168 return $this->getShipmentFilter($action);
169 }
170}
getFilter(string $entity, array $params=[])
Определения StoreDocumentFilter.php:25
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$action
Определения file_dialog.php:21