Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
agreement.php
1
<?php
2
namespace
Bitrix\Main\Controller
;
3
4
use
Bitrix\Main\Engine
;
5
use
Bitrix\Main\Engine\ActionFilter\Authentication
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Text\Encoding
;
8
use
Bitrix\Main\UI\Extension
;
9
use
Bitrix\Main\UserConsent
;
10
11
class
Agreement
extends
Engine\Controller
12
{
13
public
function
configureActions
()
14
{
15
return
[
16
'get'
=> [
17
'-prefilters'
=> [
18
Authentication::class
,
19
Engine\ActionFilter\Csrf::class,
20
],
21
],
22
];
23
}
24
25
public
function
getAction
(
int
$id,
string
$sec, array $replace): array
26
{
27
$agreement = $this->getAgreement($id, $sec);
28
if
(!$agreement)
29
{
30
return
[];
31
}
32
33
$agreement->setReplace($replace);
34
35
$result = [
36
'id'
=> $agreement->getId(),
37
'title'
=> $agreement->getTitle(),
38
'label'
=> $agreement->getLabel(),
39
'url'
=> $agreement->getUrl(),
40
'content'
=> [
41
'text'
=> $agreement->getText(),
42
'html'
=> $agreement->getHtml(),
43
],
44
];
45
46
return
$result;
47
}
48
49
private
function
getAgreement(
int
$id,
string
$sec): ?UserConsent\
Agreement
50
{
51
$agreement =
new
UserConsent\Agreement
($id);
52
if
(!$agreement->isExist() || !$agreement->isActive())
53
{
54
$this->
addError
(
new
Error
(
'Agreement not found'
));
55
return
null
;
56
}
57
58
$secStored = $agreement->getData()[
'SECURITY_CODE'
] ??
''
;
59
if
($secStored && $sec !== $secStored)
60
{
61
$this->
addError
(
new
Error
(
'Wrong security code'
));
62
return
null
;
63
}
64
65
return
$agreement;
66
}
67
}
68
Bitrix\Main\Controller\Agreement
Definition
agreement.php:12
Bitrix\Main\Controller\Agreement\configureActions
configureActions()
Definition
agreement.php:13
Bitrix\Main\Controller\Agreement\getAction
getAction(int $id, string $sec, array $replace)
Definition
agreement.php:25
Bitrix\Main\DB\Connection\$host
$host
Definition
connection.php:29
Bitrix\Main\Engine\ActionFilter\Authentication
Definition
authentication.php:14
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Text\Encoding
Definition
encoding.php:8
Bitrix\Main\UI\Extension
Definition
extension.php:11
Bitrix\Main\UserConsent\Agreement
Definition
agreement.php:25
Bitrix\Main\Controller
Definition
agreement.php:2
Bitrix\Main\Engine
Definition
action.php:3
Bitrix\Main\UserConsent
Definition
agreement.php:8
modules
main
lib
controller
agreement.php
Создано системой
1.10.0