Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
SidebarFilterProcessorTrait.php
1<?php
2
3namespace Bitrix\Im\V2\Common;
4
6
7trait SidebarFilterProcessorTrait
8{
9 protected static function processSidebarFilters(Query $query, array $filter, array $order, $fieldsMap = []): void
10 {
11 if (isset($filter['USER_ID']))
12 {
13 $query->whereIn($fieldsMap['AUTHOR_ID'] ?? 'AUTHOR_ID', $filter['USER_ID']);
14 }
15
16 if (isset($filter['LAST_ID']))
17 {
18 $operator = $order[$fieldsMap['ID'] ?? 'ID'] === 'DESC' ? '<' : '>';
19 $query->where($fieldsMap['ID'] ?? 'ID', $operator, $filter['LAST_ID']);
20 }
21
22 if (isset($filter['CHAT_ID']))
23 {
24 $query->where($fieldsMap['CHAT_ID'] ?? 'CHAT_ID', $filter['CHAT_ID']);
25 }
26
27 if (isset($filter['DATE_FROM']))
28 {
29 $query->where($fieldsMap['DATE_CREATE'] ?? 'DATE_CREATE', '>=', $filter['DATE_FROM']);
30 }
31
32 if (isset($filter['DATE_TO']))
33 {
34 $query->where($fieldsMap['DATE_CREATE'] ?? 'DATE_CREATE', '<=', $filter['DATE_TO']);
35 }
36
37 if (isset($filter['START_ID']) && (int)$filter['START_ID'] > 0)
38 {
39 $query->where($fieldsMap['MESSAGE_ID'] ?? 'MESSAGE_ID', '>=', $filter['START_ID']);
40 }
41 }
42}