Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
consentpreview.php
1
<?php
2
3
namespace
Bitrix\Sender\UI\Controller
;
4
5
use
Bitrix\Main\Engine\ActionFilter
;
6
use
Bitrix\Main\Engine\JsonController
;
7
use
Bitrix\Main\Engine\JsonPayload
;
8
use
Bitrix\Main
;
9
use
Bitrix\Sender\Preset\Templates\Consent
;
10
use
Bitrix\Sender\Security
;
11
12
class
ConsentPreview
extends
JsonController
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
}
Bitrix\Main\Engine\ActionFilter\HttpMethod\METHOD_POST
const METHOD_POST
Definition
httpmethod.php:15
Bitrix\Main\Engine\Controller\$request
$request
Definition
controller.php:48
Bitrix\Main\Engine\JsonController
Definition
jsoncontroller.php:9
Bitrix\Main\Engine\JsonPayload
Definition
jsonpayload.php:13
Bitrix\Main\Engine\JsonPayload\getData
getData()
Definition
jsonpayload.php:19
Bitrix\Main\UserConsent\Agreement
Definition
agreement.php:25
Bitrix\Sender\Consent\Consent
Definition
consent.php:16
Bitrix\Sender\Preset\Templates\Consent\getRejectnBtnText
static getRejectnBtnText()
Definition
consent.php:77
Bitrix\Sender\Preset\Templates\Consent\getApproveBtnText
static getApproveBtnText($agreement)
Definition
consent.php:71
Bitrix\Sender\Security\Agreement
Definition
agreement.php:15
Bitrix\Sender\UI\Controller\ConsentPreview
Definition
consentpreview.php:13
Bitrix\Sender\UI\Controller\ConsentPreview\getDefaultPreFilters
getDefaultPreFilters()
Definition
consentpreview.php:14
Bitrix\Sender\UI\Controller\ConsentPreview\loadDataAction
loadDataAction(JsonPayload $payload)
Definition
consentpreview.php:24
Bitrix\Main\Engine\ActionFilter
Definition
authentication.php:4
Bitrix\Main
Bitrix\Sender\Security
Definition
access.php:3
Bitrix\Sender\UI\Controller
Definition
consentpreview.php:3
modules
sender
lib
ui
controller
consentpreview.php
Создано системой
1.10.0