Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
handler.php
1<?php
9
12
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 {
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}
static OnUISelectorGetProviderByEntityType(Event $event)
Definition handler.php:17
static OnUISelectorFillLastDestination(Event $event)
Definition handler.php:46
getParameter($key)
Definition event.php:80