Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
allowedsender.php
1
<?php
2
10
namespace
Bitrix\Sender\Integration\Sender
;
11
12
use
Bitrix\Main\Localization\Loc
;
13
use
Bitrix\Main\Mail\Address
;
14
15
Loc::loadMessages
(__FILE__);
16
17
class
AllowedSender
18
{
24
public
static
function
getList
($forUserId =
null
)
25
{
26
$result = \Bitrix\Main\Mail\Sender::prepareUserMailboxes($forUserId);
27
if
(!\
Bitrix
\
Sender
\Integration\Bitrix24\Service::isCloud())
28
{
29
$addressFromList = \Bitrix\Sender\MailingChainTable::getEmailFromList();
30
31
$address =
new
Address
();
32
foreach
($addressFromList as $email)
33
{
34
$address->set($email);
35
$formatted = $address->get();
36
if
(!$formatted)
37
{
38
continue
;
39
}
40
41
$result[] = [
42
'name'
=> $address->getName(),
43
'email'
=> $address->getEmail(),
44
'formatted'
=> $address->get(),
45
];
46
}
47
}
48
return
$result;
49
}
50
57
public
static
function
isAllowed
($email, $userId =
null
)
58
{
59
if
($email ==
''
)
60
{
61
return
false
;
62
}
63
64
$address =
new
Address
();
65
$address->set($email);
66
$normalizedEmail = $address->getEmail();
67
if
(!$normalizedEmail)
68
{
69
return
false
;
70
}
71
$normalizedEmail = mb_strtolower($normalizedEmail);
72
$allowedSenders =
self::getList
($userId);
73
if
(empty(array_filter($allowedSenders,
function
($item) use ($normalizedEmail)
74
{
75
return
mb_strtolower($item[
'email'
]) === $normalizedEmail;
76
})))
77
{
78
return
false
;
79
}
80
81
return
true
;
82
}
83
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Mail\Address
Definition
address.php:16
Bitrix\Sender\Integration\Sender\AllowedSender
Definition
allowedsender.php:18
Bitrix\Sender\Integration\Sender\AllowedSender\isAllowed
static isAllowed($email, $userId=null)
Definition
allowedsender.php:57
Bitrix\Sender\Integration\Sender\AllowedSender\getList
static getList($forUserId=null)
Definition
allowedsender.php:24
Bitrix\Sender\Posting\Sender
Definition
sender.php:44
Bitrix\Sender\Integration\Sender
Definition
allowedsender.php:10
Bitrix
modules
sender
lib
integration
sender
allowedsender.php
Создано системой
1.10.0