1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearcounteritem.php
См. документацию.
1<?php
2
3namespace Bitrix\Iblock\Grid\Row\Actions\Item;
4
5use Bitrix\Main\AccessDeniedException;
6use Bitrix\Main\Error;
7use Bitrix\Main\HttpRequest;
8use Bitrix\Main\Localization\Loc;
9use Bitrix\Main\Result;
10use CIBlockElement;
11use CUtil;
12
13final class ClearCounterItem extends BaseItem
14{
15 public static function getId(): ?string
16 {
17 return 'clear_counter';
18 }
19
20 protected function getText(): string
21 {
22 return Loc::getMessage('IBLOCK_GRID_ROW_ACTIONS_CLEAR_COUNTER_NAME');
23 }
24
25 public function getControl(array $rawFields): ?array
26 {
27 $id = (int)($rawFields['ID'] ?? 0);
28 if ($id <= 0)
29 {
30 return null;
31 }
32
33 $actionId = self::getId();
34 $data = CUtil::PhpToJSObject([
35 'id' => $id,
36 ]);
37
38 $this->onclick = "IblockGridInstance.sendRowAction('{$actionId}', {$data})";
39
40 return parent::getControl($rawFields);
41 }
42
44 {
45 $id = $request->getPost('id');
46 if (empty($id) || !is_numeric($id))
47 {
48 return null;
49 }
50 $id = (int)$id;
51
52 if (!$this->getIblockRightsChecker()->canEditElement($id))
53 {
54 throw new AccessDeniedException('Cannot edit element');
55 }
56
57 $result = new Result();
58
59 $entity = new CIBlockElement();
60 $updateResult = $entity->Update($id, [
61 'SHOW_COUNTER' => false,
62 'SHOW_COUNTER_START' => false,
63 ]);
64 if (!$updateResult)
65 {
66 $message = $entity->getLastError() ?: 'Cannot update element';
67 $result->addError(new Error($message));
68 }
69
70 return $result;
71 }
72}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
Определения error.php:15
$data['IS_AVAILABLE']
Определения .description.php:13
</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
$message
Определения payment.php:8