25 use SectionSelectControl;
28 public static function getId(): string
35 return Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_ACTIONS_ELEMENT_GROUP_ADD_TO_SECTION_NAME');
42 $controls = $request->getPost(
'controls');
43 if (!is_array($controls))
48 $sectionId = (int)($controls[
'section_id'] ?? 0);
54 if ($isSelectedAllRows)
56 $elementIds = $this->getElementIdsByFilter($filter);
67 $elementIds = $this->validateElementIds($elementIds);
73 $this->addElementsToSection($sectionId, $elementIds)->
getErrors()
84 'ACTION' => Actions::RESET_CONTROLS,
87 'ACTION' => Actions::CREATE,
89 $this->getSectionSelectControl(
false),
90 (
new Snippet)->getSendSelectedButton(),
96 private function addElementsToSection(
int $sectionId, array $ids):
Result
99 $entity =
new CIBlockElement();
103 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_ADD_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_BIND_ELEMENT', [
104 '#ID#' => $sectionId,
113 foreach ($ids as $id)
117 $message =
Loc::getMessage(
'IBLOCK_GRID_PANEL_UI_ADD_TO_SECTION_GROUP_CHILD_ACCESS_DENIED_EDIT_ELEMENT', [
118 '#ID#' => $sectionId,
128 'IBLOCK_SECTION' => [
130 ...$this->getElementSectionsIds($id),
133 $updateResult = $entity->Update($id, $fields);
136 if ($entity->getLastError())
139 new Error($entity->getLastError())
145 $ipropValues =
new ElementValues($this->
getIblockId(), $id);
146 $ipropValues->clearValues();
153 private function getElementSectionsIds(
int $elementId): array
157 $rows = CIBlockElement::GetElementGroups($elementId,
true, [
'ID']);
158 while ($row = $rows->Fetch())
160 $result[] = (int)$row[
'ID'];
getRequestRows(HttpRequest $request)
static getMessage($code, $replace=null, $language=null)