1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearcountergroupchild.php
См. документацию.
1<?php
2
3namespace Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup;
4
5use Bitrix\Iblock\Grid\ActionType;
6use Bitrix\Iblock\Grid\Panel\UI\Actions\Helpers\ItemFinder;
7use Bitrix\Iblock\Grid\RowType;
8use Bitrix\Main\Error;
9use Bitrix\Main\Filter\Filter;
10use Bitrix\Main\Grid\Panel\Actions;
11use Bitrix\Main\Grid\Panel\Snippet;
12use Bitrix\Main\Grid\Panel\Snippet\Onchange;
13use Bitrix\Main\HttpRequest;
14use Bitrix\Main\Localization\Loc;
15use Bitrix\Main\Result;
16use CIBlockElement;
17
22{
23 use ItemFinder;
24
25 public static function getId(): string
26 {
28 }
29
30 public function getName(): string
31 {
32 return Loc::getMessage('IBLOCK_GRID_PANEL_UI_ACTIONS_ELEMENT_GROUP_CLEAR_COUNTER_NAME');
33 }
34
35 public function processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter = null): ?Result
36 {
37 $result = new Result();
38
39 if ($isSelectedAllRows)
40 {
41 $elementIds = $this->getElementIdsByFilter($filter);
42 }
43 else
44 {
45 $ids = $this->getRequestRows($request);
46 if (empty($ids))
47 {
48 return null;
49 }
50
51 [$elementIds,] = RowType::parseIndexList($ids);
52 $elementIds = $this->validateElementIds($elementIds);
53 }
54 if ($elementIds)
55 {
56 $result->addErrors(
57 $this->processClearCounterElements($elementIds)->getErrors()
58 );
59 }
60
61 return $result;
62 }
63
64 protected function getOnchange(): Onchange
65 {
66 return new Onchange([
67 [
68 'ACTION' => Actions::RESET_CONTROLS,
69 ],
70 [
71 'ACTION' => Actions::CREATE,
72 'DATA' => [
73 (new Snippet)->getSendSelectedButton(),
74 ],
75 ],
76 ]);
77 }
78
79 private function processClearCounterElements(array $ids): Result
80 {
81 $result = new Result();
82 $entity = new CIBlockElement();
83
84 foreach ($ids as $id)
85 {
86 if (!$this->getIblockRightsChecker()->canEditElement($id))
87 {
88 $message = Loc::getMessage('IBLOCK_GRID_PANEL_ELEMENT_ACTION_PANEL_ERROR_ACCESS_DENIED', [
89 '#ID#' => $id,
90 ]);
91 $result->addError(
92 new Error($message)
93 );
94
95 continue;
96 }
97
98 $fields = [
99 'SHOW_COUNTER' => false,
100 'SHOW_COUNTER_START' => false,
101 ];
102 $updateResult = $entity->Update($id, $fields);
103 if (!$updateResult && $entity->getLastError())
104 {
105 $result->addError(
106 new Error($entity->getLastError())
107 );
108 }
109 }
110
111 return $result;
112 }
113}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
const CLEAR_COUNTER
Определения actiontype.php:9
processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter=null)
Определения clearcountergroupchild.php:35
static parseIndexList(array $ids)
Определения rowtype.php:50
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$entity
$filter
Определения iblock_catalog_list.php:54
getErrors()
Определения errorableimplementation.php:34
$message
Определения payment.php:8
$fields
Определения yandex_run.php:501