Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
agreement.php
1
<?php
2
3
namespace
Bitrix\Sender\Security
;
4
5
use
Bitrix\Main\Context
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Sender\Internals\Model\AgreementTable
;
8
9
14
class
Agreement
15
{
22
public
static
function
isAcceptedByUser
($userId)
23
{
24
$agreement = AgreementTable::getRow(array(
25
'select'
=> array(
'ID'
),
26
'filter'
=> array(
'=USER_ID'
=> $userId),
27
'limit'
=> 1,
28
'cache'
=> array(
'ttl'
=> 3600)
29
));
30
31
return
!empty($agreement);
32
}
33
39
public
static
function
requestFromCurrentUser
()
40
{
41
if
(
User::current
()->isAgreementAccepted())
42
{
43
return
;
44
}
45
46
\CJSCore::init(array(
'sender_agreement'
));
47
}
48
54
public
static
function
acceptByCurrentUser
()
55
{
56
if
(
User::current
()->isAgreementAccepted())
57
{
58
return
true
;
59
}
60
61
$result = AgreementTable::add(array(
62
'USER_ID'
=>
User::current
()->getId(),
63
'NAME'
=>
User::current
()->getObject()->GetFullName(),
64
'EMAIL'
=>
User::current
()->getObject()->GetEmail(),
65
'IP_ADDRESS'
=>
Context::getCurrent
()->getRequest()->getRemoteAddress(),
66
));
67
68
return
$result->isSuccess();
69
}
70
77
public
static
function
getText
($asRichHtml =
false
)
78
{
79
Loc::loadMessages
(__FILE__);
80
81
if
($asRichHtml)
82
{
83
$msg =
Loc::getMessage
(
"SENDER_SECURITY_AGREEMENT_HTML_RICH"
);
84
}
85
else
86
{
87
$msg =
Loc::getMessage
(
"SENDER_SECURITY_AGREEMENT_HTML_RICH"
);
88
}
89
90
return
$msg;
91
}
92
98
public
static
function
getErrorText
()
99
{
100
Loc::loadMessages
(__FILE__);
101
102
return
Loc::getMessage
(
"SENDER_SECURITY_AGREEMENT_ERROR"
);
103
}
104
}
Bitrix\Main\Context\getCurrent
static getCurrent()
Definition
context.php:241
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Sender\Internals\Model\AgreementTable
Definition
agreement.php:27
Bitrix\Sender\Security\Agreement
Definition
agreement.php:15
Bitrix\Sender\Security\Agreement\getText
static getText($asRichHtml=false)
Definition
agreement.php:77
Bitrix\Sender\Security\Agreement\isAcceptedByUser
static isAcceptedByUser($userId)
Definition
agreement.php:22
Bitrix\Sender\Security\Agreement\getErrorText
static getErrorText()
Definition
agreement.php:98
Bitrix\Sender\Security\Agreement\requestFromCurrentUser
static requestFromCurrentUser()
Definition
agreement.php:39
Bitrix\Sender\Security\Agreement\acceptByCurrentUser
static acceptByCurrentUser()
Definition
agreement.php:54
Bitrix\Sender\Security\User\current
static current()
Definition
user.php:46
Bitrix\Main\Context
Definition
culture.php:9
Bitrix\Sender\Security
Definition
access.php:3
modules
sender
lib
security
agreement.php
Создано системой
1.10.0