Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
conversionhandler.php
1
<?php
8
namespace
Bitrix\Sender\Internals
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Conversion\DayContext
;
12
use
Bitrix\Main\Context
;
13
use
Bitrix\Sender\MailingChainTable
;
14
use
Bitrix\Sender\PostingRecipientTable
;
15
16
Loc::loadMessages
(__FILE__);
17
18
class
ConversionHandler
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
}
Bitrix\Conversion\DayContext
Definition
daycontext.php:14
Bitrix\Conversion\Internals\BaseContext\setAttribute
setAttribute($name, $value=null)
Definition
basecontext.php:101
Bitrix\Main\Context\getCurrent
static getCurrent()
Definition
context.php:241
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Sender\Internals\ConversionHandler
Definition
conversionhandler.php:19
Bitrix\Sender\Internals\ConversionHandler\onSetDayContextAttributes
static onSetDayContextAttributes(DayContext $context)
Definition
conversionhandler.php:41
Bitrix\Sender\Internals\ConversionHandler\CLICK_PARAM_NAME
const CLICK_PARAM_NAME
Definition
conversionhandler.php:20
Bitrix\Sender\Internals\ConversionHandler\onGetAttributeTypes
static onGetAttributeTypes()
Definition
conversionhandler.php:62
Bitrix\Sender\Internals\ConversionHandler\onAfterRecipientClick
static onAfterRecipientClick($data)
Definition
conversionhandler.php:22
Bitrix\Sender\Internals\ConversionHandler\onBeforeProlog
static onBeforeProlog()
Definition
conversionhandler.php:32
Bitrix\Sender\MailingChainTable
Definition
mailingchain.php:32
Bitrix\Sender\PostingRecipientTable
Definition
posting.php:663
Bitrix\Main\Context
Definition
culture.php:9
Bitrix\Sender\Internals
modules
sender
lib
internals
conversionhandler.php
Создано системой
1.10.0