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