Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
contact.php
1
<?php
9
namespace
Bitrix\Sender\Integration\Sender\Connectors
;
10
11
use
Bitrix\Main\Entity
;
12
use
Bitrix\Main\Localization\Loc
;
13
use
Bitrix\Sender\Connector
;
14
use
Bitrix\Sender\ContactTable
;
15
use
Bitrix\Sender\ListTable
;
16
use
Bitrix\Sender\Recipient\Type
as RecipientType;
17
18
Loc::loadMessages
(__FILE__);
19
20
class
Contact
extends
Connector\BaseFilter
21
{
25
public
function
getName
()
26
{
27
return
Loc::getMessage
(
'SENDER_INTEGRATION_SENDER_CONNECTOR_CONTACT_NAME1'
);
28
}
29
33
public
function
getCode
()
34
{
35
return
"contact_list"
;
36
}
37
43
public
function
getDataCountByType
()
44
{
45
$listId = $this->
getFieldValue
(
'LIST_ID'
,
null
);
46
if
(!$listId)
47
{
48
return
array();
49
}
50
51
$query = ContactTable::query();
52
$query->addSelect(
'TYPE_ID'
);
53
$query->addSelect(
new
Entity
\
ExpressionField
(
'CNT'
,
'COUNT(TYPE_ID)'
));
54
$query->addFilter(
'=CONTACT_LIST.LIST_ID'
, $listId);
55
$query->addGroup(
'TYPE_ID'
);
56
$list = $query->exec();
57
58
$result = array();
59
foreach
($list as $item)
60
{
61
$typeName =
RecipientType::getCode
($item[
'TYPE_ID'
]);
62
$result[$typeName] = $item[
'CNT'
];
63
}
64
65
return
$result;
66
}
67
72
public
function
getData
()
73
{
74
$listId = $this->
getFieldValue
(
'LIST_ID'
,
null
);
75
if
(!$listId)
76
{
77
return
array();
78
}
79
80
$resultDb = ContactTable::getList(
81
[
82
'select'
=> [
'NAME'
,
'TYPE_ID'
,
'CODE'
,
'USER_ID'
],
83
'filter'
=> [
84
'=CONTACT_LIST.LIST_ID'
=> $listId
85
]
86
]
87
);
88
$resultDb->addFetchDataModifier(
89
function
($data)
90
{
91
$row = array(
92
'NAME'
=> $data[
'NAME'
],
93
'USER_ID'
=> $data[
'USER_ID'
],
94
);
95
96
$key =
RecipientType::getCode
($data[
'TYPE_ID'
]);
97
$row[$key] = $data[
'CODE'
];
98
99
return
$row;
100
}
101
);
102
103
return
$resultDb;
104
}
105
111
public
static
function
getUiFilterFields
()
112
{
113
$list = array();
114
115
$list[] = array(
116
"id"
=>
"LIST_ID"
,
117
"name"
=>
Loc::getMessage
(
'SENDER_INTEGRATION_SENDER_CONNECTOR_CONTACT_FILTER_LIST_ID'
),
118
"type"
=>
"list"
,
119
"items"
=> ListTable::getList(array(
'select'
=> array(
'VALUE'
=>
'ID'
,
'NAME'
)))->fetchAll(),
120
"default"
=>
true
121
);
122
123
return
$list;
124
}
125
}
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\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\ExpressionField
Definition
expressionfield.php:25
Bitrix\Sender\Connector\BaseFilter
Definition
basefilter.php:20
Bitrix\Sender\Connector\Base\getFieldValue
getFieldValue($name, $defaultValue=null)
Definition
base.php:195
Bitrix\Sender\ContactTable
Definition
contact.php:43
Bitrix\Sender\Entity\Contact
Definition
contact.php:26
Bitrix\Sender\Integration\Sender\Connectors\Contact\getName
getName()
Definition
contact.php:25
Bitrix\Sender\Integration\Sender\Connectors\Contact\getUiFilterFields
static getUiFilterFields()
Definition
contact.php:111
Bitrix\Sender\Integration\Sender\Connectors\Contact\getData
getData()
Definition
contact.php:72
Bitrix\Sender\Integration\Sender\Connectors\Contact\getCode
getCode()
Definition
contact.php:33
Bitrix\Sender\Integration\Sender\Connectors\Contact\getDataCountByType
getDataCountByType()
Definition
contact.php:43
Bitrix\Sender\Internals\ClassConstant\getCode
static getCode($id)
Definition
classconstant.php:157
Bitrix\Sender\ListTable
Definition
list.php:34
Bitrix\Sender\Recipient\Type
Definition
type.php:20
Bitrix\Sender\Connector
Definition
base.php:8
Bitrix\Sender\Integration\Sender\Connectors
Definition
blacklist.php:9
modules
sender
lib
integration
sender
connectors
contact.php
Создано системой
1.10.0