132 $query = UserTable::query();
141 'BOT_TYPE' =>
'im_bot.TYPE',
142 'BOT_COUNT_MESSAGE' =>
'im_bot.COUNT_MESSAGE',
145 $query->registerRuntimeField(
149 Join::on(
'this.ID',
'ref.BOT_ID'),
150 [
'join_type' => Join::TYPE_INNER]
156 $query->registerRuntimeField(
159 \
Bitrix\Main\UserIndexTable::class,
160 Join::on(
'this.ID',
'ref.USER_ID'),
161 [
'join_type' =>
'INNER']
166 'USER_INDEX.SEARCH_USER_CONTENT',
167 Filter\Helper::matchAgainstWildcard(
168 Content::prepareStringToken(
$options[
'searchQuery']),
'*', 1
173 if (isset(
$options[
'searchableBotTypes']) && is_array(
$options[
'searchableBotTypes']))
175 $query->whereIn(
'BOT_TYPE',
$options[
'searchableBotTypes']);
179 $userFilter = isset(
$options[
'userId']) ?
'userId' : (isset(
$options[
'!userId']) ?
'!userId' :
null);
184 foreach (
$options[$userFilter] as $id)
193 $userIds = array_unique($userIds);
195 if (!empty($userIds))
197 if ($userFilter ===
'userId')
199 $query->whereIn(
'ID', $userIds);
203 $query->whereNotIn(
'ID', $userIds);
207 else if (!is_array(
$options[$userFilter]) && (
int)
$options[$userFilter] > 0)
209 if ($userFilter ===
'userId')
211 $query->where(
'ID', (
int)
$options[$userFilter]);
215 $query->whereNot(
'ID', (
int)
$options[$userFilter]);
222 $query->setLimit(
$options[
'limit']);
226 $query->setLimit(100);
231 $query->setOrder(
$options[
'order']);
236 'BOT_COUNT_MESSAGE' =>
'DESC'
240 $result = $query->exec();
242 return $result->fetchCollection();
356 if (!$this->
getOption(
'fillDialogWithDefaultValues',
true))
358 $recentBots =
new EO_User_Collection();
359 $recentItems = $dialog->
getRecentItems()->getEntityItems(
'im-bot');
360 $recentIds = array_map(
'intval', array_keys($recentItems));
361 $this->fillRecentBots($recentBots, $recentIds,
new EO_User_Collection());
368 $maxBotsInRecentTab = 50;
372 'order' => [
'ID' =>
'DESC'],
373 'limit' => $maxBotsInRecentTab
376 if (count($preloadedBots) < $maxBotsInRecentTab)
382 $entity->setDynamicSearch(
false);
386 $recentBots =
new EO_User_Collection();
389 $recentItems = $dialog->
getRecentItems()->getEntityItems(
'im-bot');
390 $recentIds = array_map(
'intval', array_keys($recentItems));
391 $this->fillRecentBots($recentBots, $recentIds, $preloadedBots);
394 if (count($recentBots) < $maxBotsInRecentTab)
397 $recentGlobalIds = [];
399 if (!empty($recentGlobalItems))
401 $recentGlobalIds = array_map(
'intval', array_keys($recentGlobalItems));
402 $recentGlobalIds = array_values(array_diff($recentGlobalIds, $recentBots->getIdList()));
403 $recentGlobalIds = array_slice($recentGlobalIds, 0, $maxBotsInRecentTab - $recentBots->count());
406 $this->fillRecentBots($recentBots, $recentGlobalIds, $preloadedBots);
410 foreach ($preloadedBots as $preloadedBot)
412 $recentBots->add($preloadedBot);