Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
relation.php
1
<?php
2
namespace
Bitrix\Im\Model
;
3
4
use
Bitrix\Im\Internals\Query
;
5
use
Bitrix\Main\Application
;
6
use
Bitrix\Main\Entity
;
7
use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
8
9
50
class
RelationTable
extends
Entity\DataManager
51
{
52
use DeleteByFilterTrait;
53
59
public
static
function
getTableName
()
60
{
61
return
'b_im_relation'
;
62
}
63
69
public
static
function
getMap
()
70
{
71
return
array(
72
'ID'
=> array(
73
'data_type'
=>
'integer'
,
74
'primary'
=>
true
,
75
'autocomplete'
=>
true
,
76
//'title' => Loc::getMessage('RELATION_ENTITY_ID_FIELD'),
77
),
78
'CHAT_ID'
=> array(
79
'data_type'
=>
'integer'
,
80
'required'
=>
true
,
81
//'title' => Loc::getMessage('RELATION_ENTITY_CHAT_ID_FIELD'),
82
),
83
'MESSAGE_TYPE'
=> array(
84
'data_type'
=>
'string'
,
85
'validation'
=> array(__CLASS__,
'validateMessageType'
),
86
//'title' => Loc::getMessage('RELATION_ENTITY_MESSAGE_TYPE_FIELD'),
87
),
88
'USER_ID'
=> array(
89
'data_type'
=>
'integer'
,
90
'required'
=>
true
,
91
//'title' => Loc::getMessage('RELATION_ENTITY_USER_ID_FIELD'),
92
),
93
'START_ID'
=> array(
94
'data_type'
=>
'integer'
,
95
//'title' => Loc::getMessage('RELATION_ENTITY_START_ID_FIELD'),
96
),
97
'LAST_ID'
=> array(
98
'data_type'
=>
'integer'
,
99
//'title' => Loc::getMessage('RELATION_ENTITY_LAST_ID_FIELD'),
100
),
101
'UNREAD_ID'
=> array(
102
'data_type'
=>
'integer'
,
103
//'title' => Loc::getMessage('RELATION_ENTITY_UNREAD_ID_FIELD'),
104
'default'
=> 0
105
),
106
'LAST_SEND_ID'
=> array(
107
'data_type'
=>
'integer'
,
108
//'title' => Loc::getMessage('RELATION_ENTITY_LAST_SEND_ID_FIELD'),
109
),
110
'LAST_SEND_MESSAGE_ID'
=> array(
111
'data_type'
=>
'integer'
,
112
),
113
'LAST_FILE_ID'
=> array(
114
'data_type'
=>
'integer'
,
115
//'title' => Loc::getMessage('RELATION_ENTITY_LAST_FILE_ID_FIELD'),
116
),
117
'LAST_READ'
=> array(
118
'data_type'
=>
'datetime'
,
119
//'title' => Loc::getMessage('RELATION_ENTITY_LAST_READ_FIELD'),
120
),
121
'STATUS'
=> array(
122
'data_type'
=>
'integer'
,
123
//'title' => Loc::getMessage('RELATION_ENTITY_STATUS_FIELD'),
124
),
125
'CALL_STATUS'
=> array(
126
'data_type'
=>
'integer'
,
127
//'title' => Loc::getMessage('RELATION_ENTITY_CALL_STATUS_FIELD'),
128
),
129
'MESSAGE_STATUS'
=> array(
130
'data_type'
=>
'string'
,
131
'default_value'
=> IM_MESSAGE_STATUS_RECEIVED,
132
'validation'
=> array(__CLASS__,
'validateMessageStatus'
),
133
),
134
'NOTIFY_BLOCK'
=> array(
135
'data_type'
=>
'boolean'
,
136
'values'
=> array(
'N'
,
'Y'
),
137
//'title' => Loc::getMessage('RELATION_ENTITY_NOTIFY_BLOCK_FIELD'),
138
),
139
'MANAGER'
=> array(
140
'data_type'
=>
'boolean'
,
141
'values'
=> array(
'N'
,
'Y'
),
142
'default_value'
=>
'N'
,
143
),
144
'COUNTER'
=> array(
145
'data_type'
=>
'integer'
,
146
'default_value'
=> 0,
147
),
148
'START_COUNTER'
=> array(
149
'data_type'
=>
'integer'
,
150
'default_value'
=> 0,
151
),
152
'CHAT'
=> array(
153
'data_type'
=>
'Bitrix\Im\Model\ChatTable'
,
154
'reference'
=> array(
'=this.CHAT_ID'
=>
'ref.ID'
),
155
),
156
'START'
=> array(
157
'data_type'
=>
'Bitrix\Im\Model\MessageTable'
,
158
'reference'
=> array(
'=this.START_ID'
=>
'ref.ID'
),
159
),
160
'LAST_SEND'
=> array(
161
'data_type'
=>
'Bitrix\Im\Model\MessageTable'
,
162
'reference'
=> array(
'=this.LAST_SEND_ID'
=>
'ref.ID'
),
163
),
164
'LAST'
=> array(
165
'data_type'
=>
'Bitrix\Im\Model\MessageTable'
,
166
'reference'
=> array(
'=this.LAST_ID'
=>
'ref.ID'
),
167
),
168
'USER'
=> array(
169
'data_type'
=>
'Bitrix\Main\User'
,
170
'reference'
=> array(
'=this.USER_ID'
=>
'ref.ID'
),
171
),
172
);
173
}
174
180
public
static
function
validateMessageType
()
181
{
182
return
array(
183
new
Entity
\Validator\Length(
null
, 1),
184
);
185
}
186
192
public
static
function
validateMessageStatus
()
193
{
194
return
array(
195
new
Entity
\Validator\Length(
null
, 50),
196
);
197
}
198
203
public
static
function
generateSearchContent
(array $fields)
204
{
205
$result = \Bitrix\Main\Search\MapBuilder::create()
206
->addText($fields[
'TITLE'
])
207
->build();
208
209
return
$result;
210
}
211
215
public
static
function
deleteBatch
(array $filter, $limit = 0): int
216
{
217
/*
218
$tableName = static::getTableName();
219
$connection = Application::getConnection();
220
$sqlHelper = $connection->getSqlHelper();
221
222
$query = new Query(static::getEntity());
223
$query->setFilter($filter);
224
$query->getQuery();
225
226
$alias = $sqlHelper->quote($query->getInitAlias()) . '.';
227
$where = str_replace($alias, '', $query->getWhere());
228
229
$sql = 'DELETE FROM ' . $tableName . ' WHERE ' . $where;
230
if($limit > 0)
231
{
232
$sql .= ' LIMIT ' . $limit;
233
}
234
235
$connection->queryExecute($sql);
236
*/
237
238
$connection =
Application::getConnection
();
239
240
static::deleteByFilter($filter);
241
242
return
$connection->getAffectedRowsCount();
243
}
244
}
Bitrix\Im\Internals\Query
Definition
query.php:10
Bitrix\Im\Model\RelationTable
Definition
relation.php:51
Bitrix\Im\Model\RelationTable\validateMessageStatus
static validateMessageStatus()
Definition
relation.php:192
Bitrix\Im\Model\RelationTable\deleteBatch
static deleteBatch(array $filter, $limit=0)
Definition
relation.php:215
Bitrix\Im\Model\RelationTable\getMap
static getMap()
Definition
relation.php:69
Bitrix\Im\Model\RelationTable\validateMessageType
static validateMessageType()
Definition
relation.php:180
Bitrix\Im\Model\RelationTable\generateSearchContent
static generateSearchContent(array $fields)
Definition
relation.php:203
Bitrix\Im\Model\RelationTable\getTableName
static getTableName()
Definition
relation.php:59
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Im\V2\Sync\Entity
Definition
Entity.php:6
Bitrix\Im\Model
Definition
alias.php:2
modules
im
lib
model
relation.php
Создано системой
1.10.0