Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
consentpreview.php
1<?php
2
4
11
13{
14 protected function getDefaultPreFilters()
15 {
16 return [
17 new ActionFilter\Authentication(),
18 new ActionFilter\HttpMethod([ActionFilter\HttpMethod::METHOD_POST]),
19 new ActionFilter\Csrf(),
20 new ActionFilter\CloseSession()
21 ];
22 }
23
24 public function loadDataAction(JsonPayload $payload)
25 {
26 $request = $payload->getData();
27 $request = is_array($request) ? $request : [];
28
29 $agreement = $this->getAgreement((int)$request['id']);
30
31 if (!$agreement)
32 {
33 return false;
34 }
35
36 $contentBody = Security\Sanitizer::fixReplacedStyles($agreement->getHtml());
37 $contentBody = Security\Sanitizer::sanitizeHtml($contentBody, $agreement->getText());
38 return [
39 'consentBody' => $contentBody,
40 'approveBtnText' => Consent::getApproveBtnText($agreement),
41 'rejectBtnText' => Consent::getRejectnBtnText(),
42 ];
43 }
44
45 private function getAgreement(int $agreementId): ?Main\UserConsent\Agreement
46 {
47 $agreement = new Main\UserConsent\Agreement($agreementId, ['fields' => []]);
48 if (!$agreement->isActive() || !$agreement->isExist())
49 {
50 return null;
51 }
52
53 return $agreement;
54 }
55}