1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sonetrightsrecepient.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Internals\EventService\Recepients;
4
5use Bitrix\Main\DB\SqlExpression;
6use Bitrix\Main\ORM\Query\Query;
7use Bitrix\Main\UserAccessTable;
8use Bitrix\Main\UserTable;
9use Bitrix\Socialnetwork\Item\LogRight;
10
12{
13 private int $sonetLogId;
14 private ?array $logRights = null;
15
16 public function __construct(int $sonetLogId, ?array $logRights)
17 {
18 $this->sonetLogId = $sonetLogId;
19 $this->logRights = $logRights;
20 }
21
22 public function fetch(int $limit, int $offset): RecepientCollection
23 {
24 $accessCodes = (is_array($this->logRights) && !empty($this->logRights))
25 ? $this->logRights
26 : LogRight::get($this->sonetLogId)
27 ;
28
29 $recipients = [];
30
31 $query = in_array('AU', $accessCodes, true)
32 ? $this->getAllAuthorisedQuery($limit, $offset)
33 : $this->getAllByAccessCodeQuery($limit, $offset, $accessCodes)
34 ;
35
36 foreach ($query->fetchAll() as $user)
37 {
38 $userId = $user['ID'] ?? 0;
39 $isOnline = ($user['IS_ONLINE'] ?? 'Y') === 'Y';
40 $recipients[] = new Recepient((int)$userId, $isOnline);
41 }
42
43 return new RecepientCollection(...$recipients);
44 }
45
46 private function getAllAuthorisedQuery(int $limit, int $offset): \Bitrix\Main\ORM\Query\Query
47 {
48 return UserTable::query()
49 ->setDistinct()
50 ->setSelect(['ID', 'ACTIVE', 'IS_REAL_USER', 'UF_DEPARTMENT', 'IS_ONLINE'])
51 ->where('ACTIVE', '=', 'Y')
52 ->where('REAL_USER', 'expr', true)
53 ->where('UF_DEPARTMENT', '!=', false)
54 ->setLimit($limit)
55 ->setOffset($offset)
56 ;
57 }
58
59 private function getAllByAccessCodeQuery(int $limit, int $offset, array $accessCodes): \Bitrix\Main\ORM\Query\Query
60 {
61 $subQuery = (new Query(UserAccessTable::getEntity()));
62 $subQuery->setSelect(['USER_ID']);
63 $subQuery->whereIn('ACCESS_CODE', $accessCodes);
64
65 return UserTable::query()
66 ->setDistinct()
67 ->setSelect([
68 'ID',
69 'ACTIVE',
70 'IS_REAL_USER',
71 'UF_DEPARTMENT',
72 'IS_ONLINE'
73 ])
74 ->where('ACTIVE', '=', 'Y')
75 ->where('REAL_USER', 'expr', true)
76 ->where('UF_DEPARTMENT', '!=', false)
77 ->whereIn('ID', new SqlExpression($subQuery->getQuery()))
78 ->setLimit($limit)
79 ->setOffset($offset)
80 ;
81 }
82}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static get(int $logId=0)
Определения logright.php:15
</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
$user
Определения mysql_to_pgsql.php:33