Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
handler.php
1
<?php
8
namespace
Bitrix\Mail\Integration\Main\UISelector
;
9
10
use
Bitrix\Main\Event
;
11
use
Bitrix\Main\EventResult
;
12
13
class
Handler
14
{
15
const
ENTITY_TYPE_MAILCONTACTS
=
'MAILCONTACTS'
;
16
17
public
static
function
OnUISelectorGetProviderByEntityType
(
Event
$event)
18
{
19
$result =
new
EventResult
(EventResult::UNDEFINED,
null
,
'mail'
);
20
21
$entityType = $event->
getParameter
(
'entityType'
);
22
23
switch
($entityType)
24
{
25
case
self::ENTITY_TYPE_MAILCONTACTS
:
26
$provider = new \Bitrix\Mail\Integration\Main\UISelector\MailContacts;
27
break
;
28
default
:
29
$provider =
false
;
30
}
31
32
if
($provider)
33
{
34
$result =
new
EventResult
(
35
EventResult::SUCCESS,
36
array(
37
'result'
=> $provider
38
),
39
'mail'
40
);
41
}
42
43
return
$result;
44
}
45
46
public
static
function
OnUISelectorFillLastDestination
(
Event
$event)
47
{
48
$result =
new
EventResult
(EventResult::UNDEFINED,
null
,
'mail'
);
49
50
$params = $event->
getParameter
(
'params'
);
51
$destSortData = $event->
getParameter
(
'destSortData'
);
52
53
$lastDestinationList = [];
54
55
$mailContactCounter = 0;
56
57
if
(is_array($destSortData))
58
{
59
$mailContactLimit = 10;
60
61
foreach
($destSortData as $code => $sortInfo)
62
{
63
if
($mailContactCounter >= $mailContactLimit)
64
{
65
break
;
66
}
67
68
if
(preg_match(
'/^'
.
MailContacts::PREFIX
.
'(\d+)$/i'
, $code, $matches))
69
{
70
if
($mailContactCounter >= $mailContactLimit)
71
{
72
continue
;
73
}
74
if
(!isset($lastDestinationList[self::ENTITY_TYPE_MAILCONTACTS]))
75
{
76
$lastDestinationList[
self::ENTITY_TYPE_MAILCONTACTS
] = [];
77
}
78
$lastDestinationList[
self::ENTITY_TYPE_MAILCONTACTS
][$code] = $code;
79
$mailContactCounter++;
80
}
81
}
82
83
$result =
new
EventResult
(
84
EventResult::SUCCESS,
85
[
86
'lastDestinationList'
=> $lastDestinationList
87
],
88
'mail'
89
);
90
}
91
92
return
$result;
93
}
94
}
Bitrix\Mail\Integration\Main\UISelector\Handler
Definition
handler.php:14
Bitrix\Mail\Integration\Main\UISelector\Handler\OnUISelectorGetProviderByEntityType
static OnUISelectorGetProviderByEntityType(Event $event)
Definition
handler.php:17
Bitrix\Mail\Integration\Main\UISelector\Handler\ENTITY_TYPE_MAILCONTACTS
const ENTITY_TYPE_MAILCONTACTS
Definition
handler.php:15
Bitrix\Mail\Integration\Main\UISelector\Handler\OnUISelectorFillLastDestination
static OnUISelectorFillLastDestination(Event $event)
Definition
handler.php:46
Bitrix\Mail\Integration\Main\UISelector\MailContacts\PREFIX
const PREFIX
Definition
mailcontacts.php:9
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Event\getParameter
getParameter($key)
Definition
event.php:80
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Mail\Integration\Main\UISelector
Definition
handler.php:8
modules
mail
lib
integration
main
uiselector
handler.php
Создано системой
1.10.0