8use Bitrix\Tasks\Internals\SearchIndex;
9use Bitrix\Tasks\Provider\TaskList;
10use Bitrix\Tasks\Provider\TaskQuery;
34 return TaskItem::class;
39 $tasksArray = (
new TaskList())->getList($taskQuery);
41 $linkCollection =
new static();
43 foreach ($tasksArray as $row)
48 return $linkCollection;
51 public static function find(
53 array $order = [
'ID' =>
'DESC'],
58 $context = $context ?? Locator::getContext();
60 $taskQuery =
new TaskQuery($context->getUserId());
63 if (isset($order[
'ID']))
65 $taskOrder[
'IM_CHAT_ID'] = $order[
'ID'];
68 $taskFilter = static::processFilters($filter, $taskOrder);
71 ->setSelect(static::SELECT_FIELDS)
72 ->setOrder($taskOrder)
73 ->setWhere($taskFilter)
78 $taskQuery->setLimit($limit);
81 return static::initByTaskQuery($taskQuery);
88 if (isset($filter[
'CHAT_ID']))
90 $result[
'IM_CHAT_CHAT_ID'] = (int)$filter[
'CHAT_ID'];
92 if (isset($filter[
'USER_ID']))
94 $usersIds = $filter[
'USER_ID'];
95 if (!empty($usersIds))
97 $result[
'::SUBFILTER-MEMBER'] = [
99 'CREATED_BY' => $usersIds,
100 'RESPONSIBLE_ID' => $usersIds,
101 'ACCOMPLICE' => $usersIds,
102 'AUDITOR' => $usersIds,
106 if (isset($filter[
'DATE_FROM']))
108 $result[
'>=CREATED_DATE'] = $filter[
'DATE_FROM'];
110 if (isset($filter[
'DATE_TO']))
112 $result[
'<=CREATED_DATE'] = $filter[
'DATE_TO'];
114 if (isset($filter[
'SEARCH_TASK_NAME']))
116 $result[
'::SUBFILTER-FULL_SEARCH_INDEX'] = [
117 '*FULL_SEARCH_INDEX' => SearchIndex::prepareStringToSearch($filter[
'SEARCH_TASK_NAME'])
120 if (isset($filter[
'LAST_ID']))
123 if (isset($order[
'IM_CHAT_ID']) && $order[
'IM_CHAT_ID'] ===
'ASC')
127 $result[
"{$operator}IM_CHAT_ID"] = (int)$filter[
'LAST_ID'];
static getCollectionElementClass()
static initByTaskQuery(TaskQuery $taskQuery)
static processFilters(array $filter, array $order)
static find(array $filter, array $order=['ID'=> 'DESC'], ?int $limit=null, ?Context $context=null)
static initByRow(array $row)