protected function innerDelete($ID, &$errors) { if (!CCrmProduct::CheckDeletePermission($ID)) { $errors[] = 'Access denied.'; return false; } $result = CCrmProductSection::Delete($ID); if ($result !== true) { $errors[] = CCrmProductSection::GetLastError(); } return $result; }
$section->Update($renamedSectionID, array('IBLOCK_ID' => $catalogID, 'NAME' => $newSectionName)); if (!isset($_GET['AJAX_CALL'])) { LocalRedirect($arResult['SECTION_LIST_URL']); } } } } $gridActionName = 'action_button_' . $arResult['GRID_ID']; $gridAction = isset($_POST[$gridActionName]) ? $_POST[$gridActionName] : ''; if ($gridAction === 'delete' && $arResult['CAN_DELETE']) { $arIDs = isset($_POST['ID']) && is_array($_POST['ID']) ? $_POST['ID'] : array(); if (!empty($arIDs)) { $dbSection = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $catalogID, 'ID' => $arIDs, 'GLOBAL_ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'), false, array('ID')); $section = new CCrmProductSection(); while ($arSection = $dbSection->Fetch()) { $section->Delete($arSection['ID']); } } if (!isset($_GET['AJAX_CALL'])) { LocalRedirect($arResult['SECTION_LIST_URL']); } } elseif ($gridAction === 'edit' && $arResult['CAN_EDIT']) { $section = new CIBlockSection(); $arFields = isset($_POST['FIELDS']) && is_array($_POST['FIELDS']) ? $_POST['FIELDS'] : array(); $arIDs = array_keys($arFields); if (!empty($arIDs)) { $dbSection = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $catalogID, 'ID' => $arIDs, 'GLOBAL_ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'), false, array('ID')); $section = new CIBlockSection(); while ($arSection = $dbSection->Fetch()) { $sectionID = $arSection['ID']; $arSectionFields = isset($arFields[$sectionID]) ? $arFields[$sectionID] : null;
} } else { $errorMessage = ''; if ($actionData['NAME'] == 'delete' && isset($actionData['ID']) && $arResult['CAN_DELETE']) { $sId = $actionData['ID']; $elementType = ''; if (is_string($sId) && strlen($sId) > 2) { $elementType = $sId[0]; $ID = intval(substr($sId, 1)); $DB->StartTransaction(); $result = true; if ($elementType === 'P') { $result = CCrmProduct::Delete($ID); } else { if ($elementType === 'S') { $result = CCrmProductSection::Delete($ID) || CCrmProductSection::GetLastErrorCode() === CCrmProductSection::ERR_SECTION_NOT_FOUND; } } if ($result) { $DB->Commit(); } else { if ($errorMessage !== '') { $errorMessage .= '<br />'; } if ($elementType === 'P') { $errorMessage .= CCrmProduct::GetLastError(); } else { if ($elementType === 'S') { $errorMessage .= CCrmProductSection::GetLastError(); } }