1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
userphoneauth.php
См. документацию.
1
<?php
8
9
namespace
Bitrix\Main;
10
11
use Bitrix\Main\ORM\Query\Join;
12
use Bitrix\Main\ORM\Data;
13
use Bitrix\Main\ORM\Fields;
14
use Bitrix\Main\Localization\Loc;
15
32
class
UserPhoneAuthTable
extends
Data\DataManager
33
{
34
public
static
function
getTableName
()
35
{
36
return
'b_user_phone_auth'
;
37
}
38
39
public
static
function
getMap
()
40
{
41
return
array
(
42
new
Fields
\
IntegerField
(
"USER_ID"
,
array
(
43
'primary'
=>
true
,
44
)),
45
46
new
Fields
\
StringField
(
"PHONE_NUMBER"
,
array
(
47
'validation'
=>
function
() {
48
return
array
(
49
new
Fields
\
Validators
\LengthValidator(1,
null
, [
"MIN"
=> Loc::getMessage(
"user_phone_auth_err_number"
)]),
50
array
(__CLASS__,
'validatePhoneNumber'
),
51
new
Fields
\
Validators
\UniqueValidator(Loc::getMessage(
"user_phone_auth_err_duplicte"
)),
52
);
53
}
54
)),
55
56
new
Fields\SecretField
(
"OTP_SECRET"
,
array
(
57
'crypto_enabled'
=> static::cryptoEnabled(
"OTP_SECRET"
),
58
)),
59
60
new
Fields\IntegerField
(
"ATTEMPTS"
,
array
(
61
"default_value"
=> 0,
62
)),
63
64
new
Fields\BooleanField
(
"CONFIRMED"
,
array
(
65
"values"
=>
array
(
"N"
,
"Y"
),
66
"default_value"
=>
"N"
,
67
)),
68
69
new
Fields\DatetimeField
(
"DATE_SENT"
),
70
71
(
new
Fields\Relations\Reference
(
72
'USER'
,
73
UserTable::class,
74
Join::on(
'this.USER_ID'
,
'ref.ID'
)
75
))->configureJoinType(
'inner'
),
76
);
77
}
78
83
public
static
function
validatePhoneNumber
($value)
84
{
85
$phoneNumber =
PhoneNumber\Parser::getInstance
()->parse($value);
86
if
($phoneNumber->isValid())
87
{
88
return
true
;
89
}
90
else
91
{
92
return
Loc::getMessage(
"user_phone_auth_err_incorrect_number"
);
93
}
94
}
95
96
public
static
function
onBeforeAdd
(
ORM
\
Event
$event
)
97
{
98
return
static::modifyFields(
$event
);
99
}
100
101
public
static
function
onBeforeUpdate
(
ORM
\
Event
$event
)
102
{
103
return
static::modifyFields(
$event
);
104
}
105
106
protected
static
function
modifyFields
(
ORM
\
Event
$event
)
107
{
108
$fields
=
$event
->getParameter(
'fields'
);
109
$result
=
new
ORM\EventResult
();
110
$modifiedFields =
array
();
111
112
if
(isset(
$fields
[
"PHONE_NUMBER"
]))
113
{
114
//normalize the number
115
$modifiedFields[
"PHONE_NUMBER"
] = static::normalizePhoneNumber(
$fields
[
"PHONE_NUMBER"
]);
116
}
117
118
$result
->modifyFields($modifiedFields);
119
120
return
$result
;
121
}
122
123
public
static
function
normalizePhoneNumber
($number, $defaultCountry =
''
)
124
{
125
$phoneNumber =
PhoneNumber\Parser::getInstance
()->parse($number, $defaultCountry);
126
return
$phoneNumber->format(
PhoneNumber
\Format::E164);
127
}
128
}
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\EventResult
Определения
eventresult.php:5
Bitrix\Main\ORM\Data\DataManager
Определения
datamanager.php:35
Bitrix\Main\ORM\Fields\BooleanField
Определения
booleanfield.php:20
Bitrix\Main\ORM\Fields\DatetimeField
Определения
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\Relations\Reference
Определения
reference.php:26
Bitrix\Main\ORM\Fields\SecretField
Определения
secretfield.php:14
Bitrix\Main\ORM\Fields\StringField
Определения
stringfield.php:20
Bitrix\Main\PhoneNumber\Parser\getInstance
static getInstance()
Определения
parser.php:78
Bitrix\Main\UserPhoneAuthTable
Определения
userphoneauth.php:33
Bitrix\Main\UserPhoneAuthTable\getMap
static getMap()
Определения
userphoneauth.php:39
Bitrix\Main\UserPhoneAuthTable\validatePhoneNumber
static validatePhoneNumber($value)
Определения
userphoneauth.php:83
Bitrix\Main\UserPhoneAuthTable\onBeforeAdd
static onBeforeAdd(ORM\Event $event)
Определения
userphoneauth.php:96
Bitrix\Main\UserPhoneAuthTable\normalizePhoneNumber
static normalizePhoneNumber($number, $defaultCountry='')
Определения
userphoneauth.php:123
Bitrix\Main\UserPhoneAuthTable\onBeforeUpdate
static onBeforeUpdate(ORM\Event $event)
Определения
userphoneauth.php:101
Bitrix\Main\UserPhoneAuthTable\getTableName
static getTableName()
Определения
userphoneauth.php:34
Bitrix\Main\UserPhoneAuthTable\modifyFields
static modifyFields(ORM\Event $event)
Определения
userphoneauth.php:106
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Main\ORM\Fields\Validators
Определения
booleanvalidator.php:9
Bitrix\Main\ORM\Fields
Определения
arrayfield.php:9
Bitrix\Main\ORM
Bitrix\Main\PhoneNumber
Определения
format.php:3
$event
$event
Определения
prolog_after.php:141
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
main
lib
userphoneauth.php
Создано системой
1.14.0