3declare(strict_types=1);
5namespace Bitrix\Im\V2\Chat\Member\Provider;
7use Bitrix\Im\Model\RelationTable;
9use Bitrix\Im\V2\Chat\Member\MemberCollection;
10use Bitrix\Im\V2\Chat\Member\MemberCursor;
11use Bitrix\Im\V2\Common\ContextCustomer;
12use Bitrix\Main\ORM\Fields\ExpressionField;
13use Bitrix\Main\ORM\Fields\IntegerField;
14use Bitrix\Main\ORM\Query\Query;
21 Chat::ROLE_OWNER => 1,
22 Chat::ROLE_MANAGER => 2,
23 Chat::ROLE_MEMBER => 3,
35 $query = RelationTable::query()
36 ->setSelect([
'ID',
'USER_ID',
'ROLE'])
37 ->where(
'CHAT_ID', (
int)$this->chat->getId())
38 ->setOrder([
'ROLE_PRIORITY',
'ID'])
43 $rawResult =
$query->fetchAll();
50 return $this->chat->getRelations()->getUserIds();
64 $chatAuthorId = (int)$this->chat->getAuthorId();
65 $ownerRole = Chat::ROLE_OWNER;
66 $managerRole = Chat::ROLE_MANAGER;
67 $memberRole = Chat::ROLE_MEMBER;
68 $rolePriorityMap = self::ROLE_PRIORITY_MAP;
73 WHEN %s = {$chatAuthorId} THEN '{$ownerRole}'
74 WHEN %s = 'Y' THEN '{$managerRole}'
77 [
'USER_ID',
'MANAGER']
79 $query->registerRuntimeField(
'ROLE', $roleField);
84 WHEN %s = '{$ownerRole}' THEN {$rolePriorityMap[$ownerRole]}
85 WHEN %s = '{$managerRole}' THEN {$rolePriorityMap[$managerRole]}
86 ELSE {$rolePriorityMap[$memberRole]}
90 $rolePriorityField->configureValueType(IntegerField::class);
91 $query->registerRuntimeField($rolePriorityField);
96 $rolePriority = self::ROLE_PRIORITY_MAP[$cursor->role];
99 ->where(
'ROLE_PRIORITY',
'>', $rolePriority)
102 ->where(
'ROLE_PRIORITY', $rolePriority)
103 ->where(
'ID',
'>', $cursor->relationId)
static initByRawResult(array $rawResult)
prepareQuery(Query $query, ?MemberCursor $cursor)
applyCursor(Query $query, MemberCursor $cursor)
defineRoles(Query $query)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)