Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sendertable.php
1
<?php
2
3
namespace
Bitrix\Main\Mail\Internal
;
4
5
use
Bitrix\Main\Entity
;
6
use
Bitrix\Main\Config
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Security
;
9
use
Bitrix\Main\ORM\Fields
;
10
28
class
SenderTable
extends
Entity\DataManager
29
{
30
31
public
static
function
getTableName
()
32
{
33
return
'b_main_mail_sender'
;
34
}
35
36
public
static
function
add
(array $data)
37
{
38
$result = parent::add($data);
39
40
\Bitrix\Main\Mail\Sender::clearCustomSmtpCache($data[
'EMAIL'
]);
41
42
return
$result;
43
}
44
45
46
public
static
function
getObjectClass
()
47
{
48
return
Sender::class
;
49
}
50
51
// @TODO: invalidate smtp cache on update and delete
52
53
public
static
function
getMap
()
54
{
55
return
[
56
(
new
Fields\IntegerField(
"ID"
))
57
->configurePrimary(
true
)
58
->configureAutocomplete(
true
)
59
->configureTitle(
Loc::getMessage
(
"main_mail_sender_id_title"
)),
60
61
(
new
Fields\
StringField
(
"EMAIL"
))
62
->configureRequired(
true
)
63
->configureTitle(
Loc::getMessage
(
"main_mail_sender_email_title"
)),
64
65
(
new
Fields\
StringField
(
"NAME"
))
66
->configureTitle(
Loc::getMessage
(
"main_mail_sender_name_title"
)),
67
68
(
new
Fields\
IntegerField
(
"USER_ID"
))
69
->configureAutocomplete(
true
)
70
->configureTitle(
Loc::getMessage
(
"main_mail_sender_user_id_title"
)),
71
72
(
new
Fields\
BooleanField
(
"IS_CONFIRMED"
))
73
->configureStorageValues(
"0"
,
"1"
)
74
->configureDefaultValue(
"0"
)
75
->configureTitle(
Loc::getMessage
(
"main_mail_sender_is_confirmed_title"
)),
76
77
(
new
Fields\
BooleanField
(
"IS_PUBLIC"
))
78
->configureStorageValues(
"0"
,
"1"
)
79
->configureDefaultValue(
"0"
)
80
->configureTitle(
Loc::getMessage
(
"main_mail_sender_is_public_title"
)),
81
82
(
new
Fields\
ArrayField
(
"OPTIONS"
))
83
->configureSerializationPhp()
84
->configureRequired(
true
)
85
->configureTitle(
Loc::getMessage
(
"main_mail_sender_options_title"
))
86
->addSaveDataModifier(
function
($value)
87
{
88
$value = unserialize($value, [
'allowed_classes'
=>
false
]);
89
if
(!empty($value[
'smtp'
][
'password'
]))
90
{
91
$value[
'smtp'
][
'encrypted'
] =
false
;
92
93
$cryptoOptions = Config\Configuration::getValue(
'crypto'
);
94
if
(!empty($cryptoOptions[
'crypto_key'
]))
95
{
96
try
97
{
98
$cipher =
new
Security\Cipher
();
99
100
$value[
'smtp'
][
'password'
] = $cipher->encrypt(
101
$value[
'smtp'
][
'password'
],
102
$cryptoOptions[
'crypto_key'
]
103
);
104
$value[
'smtp'
][
'encrypted'
] =
true
;
105
}
106
catch
(Security\
SecurityException
$e)
107
{
108
}
109
}
110
111
$value[
'smtp'
][
'password'
] = base64_encode($value[
'smtp'
][
'password'
]);
112
}
113
114
return
serialize($value);
115
})
116
->addFetchDataModifier(
function
($value)
117
{
118
if
(!empty($value[
'smtp'
][
'password'
]))
119
{
120
$value[
'smtp'
][
'password'
] = base64_decode($value[
'smtp'
][
'password'
]);
121
122
if
(!empty($value[
'smtp'
][
'encrypted'
]))
123
{
124
$cryptoOptions = Config\Configuration::getValue(
'crypto'
);
125
if
(!empty($cryptoOptions[
'crypto_key'
]))
126
{
127
try
128
{
129
$cipher =
new
Security\Cipher
();
130
131
$value[
'smtp'
][
'password'
] = $cipher->decrypt(
132
$value[
'smtp'
][
'password'
],
133
$cryptoOptions[
'crypto_key'
]
134
);
135
unset($value[
'smtp'
][
'encrypted'
]);
136
}
catch
(Security\
SecurityException
$e)
137
{
138
}
139
}
140
}
141
}
142
143
if
(!empty($value[
'smtp'
]) && is_array($value[
'smtp'
]))
144
{
145
if
(empty($value[
'smtp'
][
'protocol'
]))
146
{
147
if
(465 == $value[
'smtp'
][
'port'
])
148
{
149
$value[
'smtp'
][
'protocol'
] =
'smtps'
;
150
}
else
if
(587 == $value[
'smtp'
][
'port'
])
151
{
152
$value[
'smtp'
][
'protocol'
] =
'smtp'
;
153
}
154
}
155
}
156
157
return
$value;
158
})
159
];
160
}
161
162
}
Bitrix\Main\DB\Connection\$host
$host
Definition
connection.php:29
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Mail\Internal\SenderTable
Definition
sendertable.php:29
Bitrix\Main\Mail\Internal\SenderTable\getMap
static getMap()
Definition
sendertable.php:53
Bitrix\Main\Mail\Internal\SenderTable\add
static add(array $data)
Definition
sendertable.php:36
Bitrix\Main\Mail\Internal\SenderTable\getObjectClass
static getObjectClass()
Definition
sendertable.php:46
Bitrix\Main\Mail\Internal\SenderTable\getTableName
static getTableName()
Definition
sendertable.php:31
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\ArrayField
Definition
arrayfield.php:19
Bitrix\Main\ORM\Fields\BooleanField
Definition
booleanfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\Security\Cipher
Definition
cipher.php:11
Bitrix\Main\Security\SecurityException
Definition
securityexception.php:5
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Mail\Internal
Definition
blacklist.php:3
Bitrix\Main\ORM\Fields
Definition
arrayfield.php:9
Bitrix\Main\Security
Definition
asymmetriccipher.php:8
modules
main
lib
mail
internal
sendertable.php
Создано системой
1.10.0