1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
config.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Controller;
4
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\Config\State;
8use Bitrix\Catalog\Store\EnableWizard\Manager;
9use Bitrix\Catalog\Store\EnableWizard\ModeList;
10use Bitrix\Catalog\Store\EnableWizard\TariffChecker;
11use Bitrix\Main\Engine\Action;
12use Bitrix\Main\Error;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Main\NotImplementedException;
15use Bitrix\Main\Result;
16use Bitrix\Main\SystemException;
17use Bitrix\Catalog\Config\Feature;
18
20{
27 protected function processBeforeAction(Action $action): ?bool
28 {
29 $r = $this->checkPermission($action->getName(), $action->getArguments());
30 if ($r->isSuccess())
31 {
32 //do nothing
33 }
34 else
35 {
36 $this->addErrors($r->getErrors());
37 return null;
38 }
39
40 return parent::processBeforeAction($action);
41 }
42
46 protected function checkPermission($name, $arguments = [])
47 {
48 $name = strtolower($name);
49
50 if (
51 $name === strtolower('inventoryManagementEnable')
52 || $name === strtolower('inventoryManagementDisable')
53 || $name === strtolower('unRegisterOnProlog')
54 )
55 {
56 $r = $this->checkModifyPermissionEntity($name, $arguments);
57 }
58 else if ($name === strtolower('isUsedInventoryManagement'))
59 {
60 $r = $this->checkReadPermissionEntity($name, $arguments);
61 }
62 else
63 {
64 $r = $this->checkPermissionEntity($name, $arguments);
65 }
66
67 return $r;
68 }
69
75 protected function checkReadPermissionEntity($name, $arguments = [])
76 {
77 $r = new Result();
78 if (!AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ))
79 {
80 $r->addError(new Error('Access denied!', ErrorCode::READ_PERMISSION_ACCESS_DENIED));
81 }
82 return $r;
83 }
84
85 protected function checkModifyPermissionEntity($name, $arguments = []): Result
86 {
87 $r = new Result();
88 if (!AccessController::getCurrent()->check(ActionDictionary::ACTION_STORE_VIEW))
89 {
90 $r->addError(new Error('Access denied!', 200040300011));
91 }
92 return $r;
93 }
94
100 protected function checkPermissionEntity($name, $arguments = [])
101 {
102 throw new NotImplementedException('Check permission entity. The method '.$name.' is not implemented.');
103 }
104
105 public function inventoryManagementEnableAction(string $mode, array $options = []): void
106 {
107 if (
108 (
109 $mode === ModeList::B24
111 )
112 || (
113 $mode === ModeList::ONEC
115 )
116 )
117 {
118 $this->addError(
119 new Error(
120 Loc::getMessage('CATALOG_CONTROLLER_CONFIG_INVENTORY_MANAGEMENT_ENABLE_DEFAULT_ERROR')
121 )
122 );
123
124 return;
125 }
126
127 $enableResult = Manager::enable($mode, $options);
128 if (!$enableResult->isSuccess())
129 {
130 $this->addErrors($enableResult->getErrors());
131 }
132 }
133
134 public function inventoryManagementDisableAction(): void
135 {
136 $disableResult = Manager::disable();
137
138 if (!$disableResult->isSuccess())
139 {
140 $this->addErrors($disableResult->getErrors());
141 }
142 }
143
144 public function isUsedInventoryManagementAction(): bool
145 {
147 }
148}
static isInventoryManagementEnabled()
Определения feature.php:148
static isUsedInventoryManagement()
Определения state.php:42
inventoryManagementEnableAction(string $mode, array $options=[])
Определения config.php:105
processBeforeAction(Action $action)
Определения config.php:27
checkModifyPermissionEntity($name, $arguments=[])
Определения config.php:85
isUsedInventoryManagementAction()
Определения config.php:144
checkPermission($name, $arguments=[])
Определения config.php:46
inventoryManagementDisableAction()
Определения config.php:134
checkReadPermissionEntity($name, $arguments=[])
Определения config.php:75
checkPermissionEntity($name, $arguments=[])
Определения config.php:100
const READ_PERMISSION_ACCESS_DENIED
Определения errorcode.php:8
addError(Error $error)
Определения controller.php:1070
addErrors(array $errors)
Определения controller.php:1083
Определения error.php:15
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
$action
Определения file_dialog.php:21