1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
UserCollection.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Entity\User;
4
5use Bitrix\Im\Model\StatusTable;
6use Bitrix\Im\V2\Entity\EntityCollection;
7use Bitrix\Main\ORM\Fields\Relations\Reference;
8use Bitrix\Main\ORM\Query\Join;
9use Bitrix\Main\UserTable;
10
17{
18 public function __construct(array $usersIds = [])
19 {
20 parent::__construct();
21
22 foreach ($usersIds as $userId)
23 {
24 $this[] = User::getInstance($userId);
25 }
26 }
27
28 public function fillOnlineData(bool $withStatus = false): void
29 {
30 $idsUsersWithoutOnlineData = [];
31
32 foreach ($this as $user)
33 {
34 if (!$user->isOnlineDataFilled($withStatus))
35 {
36 $idsUsersWithoutOnlineData[] = $user->getId();
37 }
38 }
39
40 $idsUsersWithoutOnlineData = array_unique($idsUsersWithoutOnlineData);
41
42 if (empty($idsUsersWithoutOnlineData))
43 {
44 return;
45 }
46
48 $query = UserTable::query()
49 ->setSelect($select)
50 ->whereIn('ID', $idsUsersWithoutOnlineData)
51 ;
52 if ($withStatus)
53 {
54 $query->registerRuntimeField(
55 new Reference(
56 'STATUS',
57 StatusTable::class,
58 Join::on('this.ID', 'ref.USER_ID'),
59 ['join_type' => Join::TYPE_LEFT]
60 )
61 );
62 }
63 $statusesData = $query->fetchAll() ?: [];
64
65 foreach ($statusesData as $statusData)
66 {
67 $this->getById((int)$statusData['USER_ID'])->setOnlineData($statusData, $withStatus);
68 }
69 }
70
71 public static function filterUserIds(array $userIds, callable $predicate, ?int $limit = null): array
72 {
73 $filteredUserIds = [];
74 foreach ($userIds as $userId)
75 {
76 if ($limit !== null && count($filteredUserIds) >= $limit)
77 {
78 return $filteredUserIds;
79 }
80
82 if ($predicate($user))
83 {
84 $filteredUserIds[(int)$userId] = (int)$userId;
85 }
86 }
87
88 return $filteredUserIds;
89 }
90
91 public static function hasUserByType(array $userIds, UserType $type): bool
92 {
93 $filter = static fn (User $user) => $user->getType() === $type;
94 $firstUserByType = static::filterUserIds($userIds, $filter, 1);
95
96 return !empty($firstUserByType);
97 }
98
99 public function toRestFormat(array $option = []): array
100 {
101 $this->fillOnlineData();
102
103 return parent::toRestFormat($option);
104 }
105
106 public static function getRestEntityName(): string
107 {
108 return 'users';
109 }
110
117 public function offsetSet($offset, $value): void
118 {
120 if (!$value->isExist())
121 {
122 return;
123 }
124
125 parent::offsetSet($offset, $value);
126 }
127}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
offsetSet($offset, $value)
Определения EntityCollection.php:97
toRestFormat(array $option=[])
Определения UserCollection.php:99
__construct(array $usersIds=[])
Определения UserCollection.php:18
fillOnlineData(bool $withStatus=false)
Определения UserCollection.php:28
static hasUserByType(array $userIds, UserType $type)
Определения UserCollection.php:91
static filterUserIds(array $userIds, callable $predicate, ?int $limit=null)
Определения UserCollection.php:71
const ONLINE_DATA_SELECTED_FIELDS_WITHOUT_STATUS
Определения User.php:41
const ONLINE_DATA_SELECTED_FIELDS
Определения User.php:34
static getInstance()
Определения application.php:98
</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
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
$user
Определения mysql_to_pgsql.php:33
</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
$option
Определения options.php:1711