Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
agreement.php
1<?php
2
4
8
9
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}
static getCurrent()
Definition context.php:241
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getText($asRichHtml=false)
Definition agreement.php:77