Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userconsentrequestaction.php
1<?php
2
4
7
14{
15 private function checkParams(array $fields): Sale\Result
16 {
17 $result = new Sale\Result();
18
19 if (empty($fields['ID']) || (int)$fields['ID'] <= 0)
20 {
21 $result->addError(
22 new Main\Error(
23 'id not found',
25 )
26 );
27 }
28
29 return $result;
30 }
31
32 public function run(array $fields)
33 {
34 $checkParamsResult = $this->checkParams($fields);
35 if (!$checkParamsResult->isSuccess())
36 {
37 $this->addErrors($checkParamsResult->getErrors());
38 return null;
39 }
40
41 $title = $fields['TITLE'];
42 $replaceFields = is_array($fields['FIELDS']) ? $fields['FIELDS'] : [];
43
44 $eventName = $fields['SUBMIT_EVENT_NAME'];
45 $eventName = \CUtil::JSescape($eventName);
46 $eventName = htmlspecialcharsbx($eventName);
47
48 $params = [
49 'ID' => (int)$fields['ID'],
50 'IS_CHECKED' => $fields['IS_CHECKED'] === 'Y' ? 'Y' : 'N',
51 'IS_LOADED' => $fields['IS_LOADED'] === 'Y' ? 'Y' : 'N',
52 'AUTO_SAVE' => $fields['AUTO_SAVE'] === 'Y' ? 'Y' : 'N',
53 'SUBMIT_EVENT_NAME' => $eventName,
54 'REPLACE' => array(
55 'button_caption' => $title,
56 'fields' => $replaceFields,
57 )
58 ];
59
60 return new Main\Engine\Response\Component('bitrix:main.userconsent.request', '', $params);
61 }
62}
addErrors(array $errors)
Definition action.php:213