1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Collabs.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Recent\Initializer\Source;
4
5use Bitrix\Im\Model\RelationTable;
6use Bitrix\Im\V2\Chat;
7use Bitrix\Im\V2\Recent\Initializer\BaseSource;
8use Bitrix\Im\V2\Recent\Initializer\InitialiazerResult;
9use Bitrix\Im\V2\Recent\Initializer\SourceType;
10use Bitrix\Im\V2\Recent\Initializer\Stage;
11use Bitrix\Im\V2\Recent\Initializer\StageType;
12use Bitrix\Main\ORM\Fields\Relations\Reference;
13use Bitrix\Main\ORM\Query\Join;
14use Bitrix\Main\ORM\Query\Query;
15
17{
18 protected function getBaseQuery(string $pointer, int $limit): Query
19 {
20 $lastUserId = (int)$pointer;
21
22 $query = RelationTable::query()
23 ->setDistinct()
24 ->setSelect([self::USER_ID_FIELD_NAME => 'OTHER.USER_ID'])
25 ->where('USER_ID', $this->targetId)
26 ->where('MESSAGE_TYPE', Chat::IM_TYPE_COLLAB)
27 ->registerRuntimeField($this->getSelfJoin())
28 ->whereNotNull('OTHER.USER.LAST_ACTIVITY_DATE')
29 ->setLimit($limit)
30 ->setOrder([self::USER_ID_FIELD_NAME => 'DESC'])
31 ;
32
33 if ($lastUserId)
34 {
35 $query->where(self::USER_ID_FIELD_NAME, '<', $lastUserId);
36 }
37
38 return $query;
39 }
40
41 public static function getType(): SourceType
42 {
43 return SourceType::Collabs;
44 }
45
46 protected function getResultByRaw(array $raw, int $limit): InitialiazerResult
47 {
48 $selectedItemsCount = count($raw);
49 $userIds = [];
50 $nextId = null;
51 $hasNextStep = $selectedItemsCount >= $limit;
52
53 foreach ($raw as $row)
54 {
55 $userId = (int)($row[self::USER_ID_FIELD_NAME] ?? 0);
56 $userIds[$userId] = $userId;
57 if ($userId < $nextId || $nextId === null)
58 {
59 $nextId = $userId;
60 }
61 }
62
63 return (new InitialiazerResult())
64 ->setItems($userIds)
65 ->setNextPointer((string)$nextId)
66 ->setHasNextStep($hasNextStep)
67 ->setSelectedItemsCount($selectedItemsCount)
68 ;
69 }
70
71 private function getSelfJoin(): Reference
72 {
73 return new Reference(
74 'OTHER',
75 RelationTable::class,
76 Join::on('this.CHAT_ID', 'ref.CHAT_ID')
77 ->whereColumn('this.USER_ID', '!=', 'ref.USER_ID')
78 ->where('this.MESSAGE_TYPE', Chat::IM_TYPE_COLLAB)
79 ->where('ref.MESSAGE_TYPE', Chat::IM_TYPE_COLLAB)
80 ->where('this.USER_ID', $this->targetId),
81 ['join_type' => Join::TYPE_INNER]
82 );
83 }
84}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
getBaseQuery(string $pointer, int $limit)
Определения Collabs.php:18
getResultByRaw(array $raw, int $limit)
Определения Collabs.php:46
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
Определения chain.php:3
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936