Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
conversionhandler.php
1<?php
9
15
16Loc::loadMessages(__FILE__);
17
19{
20 const CLICK_PARAM_NAME = 'BITRIX_SENDER_TO_CONVERSION_CLICK_ID';
21
22 public static function onAfterRecipientClick($data)
23 {
24 if(isset($data['RECIPIENT']) && isset($data['RECIPIENT']['ID']))
25 {
26 $_SESSION[self::CLICK_PARAM_NAME] = $data['RECIPIENT']['ID'];
27 }
28
29 return $data;
30 }
31
32 public static function onBeforeProlog()
33 {
34 $id = Context::getCurrent()->getRequest()->getQuery('bx_sender_conversion_id');
35 if(is_numeric($id) && $id > 0)
36 {
37 $_SESSION[self::CLICK_PARAM_NAME] = $id;
38 }
39 }
40
41 public static function onSetDayContextAttributes(DayContext $context)
42 {
43 $id = null;
44 if(isset($_SESSION[self::CLICK_PARAM_NAME]))
45 $id = $_SESSION[self::CLICK_PARAM_NAME];
46
47 if(!is_numeric($id) || $id <= 0)
48 return;
49
50 $recipientDb = PostingRecipientTable::getList(array(
51 'select' => array('MAILING_CHAIN_ID' => 'POSTING.MAILING_CHAIN_ID'),
52 'filter' => array(
53 'ID' => $id
54 )
55 ));
56 if ($recipient = $recipientDb->fetch())
57 {
58 $context->setAttribute('sender_chain_source', $recipient['MAILING_CHAIN_ID']);
59 }
60 }
61
62 public static function onGetAttributeTypes()
63 {
64 return array(
65 'sender_chain_source' => array(
66 'MODULE' => 'sender',
67 'GROUP' => 'source',
68 'NAME' => Loc::getMessage('sender_conversion_chain_source'),
69 'SORT' => 5100,
70 'SPLIT_BY' => 'sender_chain_source',
71 'BG_COLOR' => '#cf4343',
72 'GET_VALUES' => function (array $list)
73 {
74 $itemList = array();
75 $filter = array();
76 if($list)
77 {
78 $filter['=ID'] = $list;
79
80 $itemDb = MailingChainTable::getList(array(
81 'select' => array(
82 'ID',
83 'TITLE',
84 ),
85 'filter' => $filter,
86 ));
87
88 while ($item = $itemDb->fetch())
89 {
90 if ($item['ID'] == '')
91 {
92 continue;
93 }
94
95 $itemList[$item['ID']] = array(
96 'NAME' => $item['TITLE']
97 );
98 }
99 }
100
101 return $itemList;
102 }
103 )
104 );
105 }
106}
static getCurrent()
Definition context.php:241
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static onSetDayContextAttributes(DayContext $context)