25 use SectionSelectControl;
28 public static function getId(): string
35 return Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_ACTIONS_ELEMENT_GROUP_MOVE_TO_SECTION_NAME');
42 $controls = $request->getPost(
'controls');
43 if (!is_array($controls))
48 $destinationSectionId = (int)($controls[
'section_id'] ?? -1);
49 if ($destinationSectionId < 0)
54 [$elementIds, $sectionIds] = $this->prepareItemIds($request, $isSelectedAllRows, $filter);
59 $this->moveElementsToSection($destinationSectionId, $elementIds)->
getErrors()
66 $this->moveSectionsToSection($destinationSectionId, $sectionIds)->
getErrors()
77 'ACTION' => Actions::RESET_CONTROLS,
80 'ACTION' => Actions::CREATE,
82 $this->getSectionSelectControl(
true),
83 (
new Snippet)->getSendSelectedButton(),
89 private function moveElementsToSection(
int $sectionId, array $ids):
Result
92 $entity =
new CIBlockElement();
96 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_MOVE_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_BIND_ELEMENT', [
106 foreach ($ids as $id)
110 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_MOVE_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_EDIT_ELEMENT', [
121 'IBLOCK_SECTION_ID' => $sectionId,
122 'IBLOCK_SECTION' => [
126 $updateResult = $entity->Update($id, $fields);
129 if ($entity->getLastError())
132 new Error($entity->getLastError())
138 $ipropValues =
new ElementValues($this->
getIblockId(), $id);
139 $ipropValues->clearValues();
146 private function moveSectionsToSection(
int $sectionId, array $ids): Result
148 $result =
new Result();
149 $entity =
new CIBlockSection();
153 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_MOVE_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_BIND_ELEMENT', [
154 '#ID#' => $sectionId,
163 foreach ($ids as $id)
167 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_MOVE_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_EDIT_ELEMENT', [
180 $updateResult = $entity->Update($id, $fields);
183 if ($entity->getLastError())
186 new Error($entity->getLastError())
192 $ipropValues =
new ElementValues($this->
getIblockId(), $id);
193 $ipropValues->clearValues();
static getMessage($code, $replace=null, $language=null)