Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
clearcountergroupchild.php
1
<?php
2
3
namespace
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup
;
4
5
use
Bitrix\Iblock\Grid\ActionType
;
6
use Bitrix\Iblock\Grid\Panel\UI\Actions\Helpers\ItemFinder;
7
use
Bitrix\Iblock\Grid\RowType
;
8
use
Bitrix\Main\Error
;
9
use
Bitrix\Main\Filter\Filter
;
10
use
Bitrix\Main\Grid\Panel\Actions
;
11
use
Bitrix\Main\Grid\Panel\Snippet
;
12
use
Bitrix\Main\Grid\Panel\Snippet\Onchange
;
13
use
Bitrix\Main\HttpRequest
;
14
use
Bitrix\Main\Localization\Loc
;
15
use
Bitrix\Main\Result
;
16
use CIBlockElement;
17
21
final
class
ClearCounterGroupChild
extends
BaseGroupChild
22
{
23
use ItemFinder;
24
25
public
static
function
getId
(): string
26
{
27
return
ActionType::CLEAR_COUNTER
;
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
}
Bitrix\Iblock\Grid\ActionType
Definition
actiontype.php:5
Bitrix\Iblock\Grid\ActionType\CLEAR_COUNTER
const CLEAR_COUNTER
Definition
actiontype.php:9
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\BaseGroupChild
Definition
basegroupchild.php:9
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\BaseGroupChild\getIblockRightsChecker
getIblockRightsChecker()
Definition
basegroupchild.php:26
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\ClearCounterGroupChild
Definition
clearcountergroupchild.php:22
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\ClearCounterGroupChild\getName
getName()
Definition
clearcountergroupchild.php:30
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\ClearCounterGroupChild\processRequest
processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter=null)
Definition
clearcountergroupchild.php:35
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\ClearCounterGroupChild\getId
static getId()
Definition
clearcountergroupchild.php:25
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup\ClearCounterGroupChild\getOnchange
getOnchange()
Definition
clearcountergroupchild.php:64
Bitrix\Iblock\Grid\RowType
Definition
rowtype.php:8
Bitrix\Iblock\Grid\RowType\parseIndexList
static parseIndexList(array $ids)
Definition
rowtype.php:52
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Filter\Filter
Definition
filter.php:5
Bitrix\Main\Grid\Panel\Action\Group\GroupChildAction\getRequestRows
getRequestRows(HttpRequest $request)
Definition
groupchildaction.php:29
Bitrix\Main\Grid\Panel\Actions
Definition
actions.php:13
Bitrix\Main\Grid\Panel\Snippet\Onchange
Definition
onchange.php:15
Bitrix\Main\Grid\Panel\Snippet
Definition
snippet.php:19
Bitrix\Main\HttpRequest
Definition
httprequest.php:20
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Iblock\Grid\Panel\UI\Actions\Item\ElementGroup
Definition
activategroupchild.php:3
Bitrix\Main\Grid\Panel\Snippet
Definition
button.php:3
Bitrix\Main\getErrors
getErrors()
Definition
errorableimplementation.php:34
modules
iblock
lib
grid
panel
ui
actions
item
elementgroup
clearcountergroupchild.php
Создано системой
1.10.0