Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
projectuserprovider.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Integration\UI\EntitySelector
;
4
5
use
Bitrix\Main\ArgumentException
;
6
use Bitrix\Main\Entity\Query;
7
use
Bitrix\Main\ORM\Fields\Relations\Reference
;
8
use
Bitrix\Main\ORM\Query\Join
;
9
use
Bitrix\Main\SystemException
;
10
use
Bitrix\Main\UserTable
;
11
use
Bitrix\Socialnetwork\Helper\Workgroup
;
12
use
Bitrix\Socialnetwork\UserToGroupTable
;
13
14
class
ProjectUserProvider
extends
UserProvider
15
{
16
protected
function
prepareOptions
(array
$options
= []): void
17
{
18
parent::prepareOptions(
$options
);
19
$this->options[
'projectId'
] = (int)(
$options
[
'projectId'
] ??
null
);
20
}
21
26
protected
static
function
getQuery
(array
$options
= []):
Query
27
{
28
$projectId =
$options
[
'projectId'
];
29
if
($projectId <= 0 || !static::isMember($projectId))
30
{
31
return
static::getEmptyQuery();
32
}
33
34
return
parent::getQuery(
$options
)->registerRuntimeField(
35
'GROUP_MEMBERS'
,
36
new
Reference
(
37
'USER_TO_GROUP'
,
38
UserToGroupTable::getEntity(),
39
Join::on(
'this.ID'
,
'ref.USER_ID'
)
40
->where(
'ref.GROUP_ID'
, $projectId)
41
->whereIn(
'ref.ROLE'
,
UserToGroupTable::getRolesMember
()),
42
[
'join_type'
=> Join::TYPE_INNER]
43
)
44
);
45
}
46
47
protected
static
function
getExtranetUsersQuery
(
int
$currentUserId): ?
Query
48
{
49
// return null because static::getQuery() adds the necessary conditions
50
return
null
;
51
}
52
53
private
static
function
isMember(
int
$projectId): bool
54
{
55
$permissions =
Workgroup::getPermissions
([
56
'groupId'
=> $projectId,
57
'userId'
=> static::getCurrentUserId(),
58
]);
59
60
return
$permissions[
'UserIsMember'
] ??
false
;
61
}
62
67
private
static
function
getEmptyQuery():
Query
68
{
69
return
UserTable::query()->
setSelect
([
'ID'
])->where(
'ID'
, 0);
70
}
71
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ORM\Fields\Relations\Reference
Definition
reference.php:26
Bitrix\Main\ORM\Query\Join
Definition
join.php:19
Bitrix\Main\ORM\Query\Query
Definition
query.php:118
Bitrix\Main\ORM\Query\Query\setSelect
setSelect(array $select)
Definition
query.php:338
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\UserTable
Definition
user.php:46
Bitrix\Socialnetwork\Helper\Workgroup\getPermissions
static getPermissions(array $params=[])
Definition
workgroup.php:470
Bitrix\Socialnetwork\Integration\UI\EntitySelector\ProjectUserProvider
Definition
projectuserprovider.php:15
Bitrix\Socialnetwork\Integration\UI\EntitySelector\ProjectUserProvider\getExtranetUsersQuery
static getExtranetUsersQuery(int $currentUserId)
Definition
projectuserprovider.php:47
Bitrix\Socialnetwork\Integration\UI\EntitySelector\ProjectUserProvider\prepareOptions
prepareOptions(array $options=[])
Definition
projectuserprovider.php:16
Bitrix\Socialnetwork\Integration\UI\EntitySelector\ProjectUserProvider\getQuery
static getQuery(array $options=[])
Definition
projectuserprovider.php:26
Bitrix\Socialnetwork\Integration\UI\EntitySelector\UserProvider
Definition
userprovider.php:32
Bitrix\Socialnetwork\UserToGroupTable
Definition
usertogroup.php:33
Bitrix\Socialnetwork\UserToGroupTable\getRolesMember
static getRolesMember()
Definition
usertogroup.php:73
Bitrix\UI\EntitySelector\BaseProvider\$options
$options
Definition
baseprovider.php:6
Bitrix\Socialnetwork\Helper\Workgroup
Definition
access.php:9
Bitrix\Socialnetwork\Integration\UI\EntitySelector
Definition
fireduserprovider.php:3
modules
socialnetwork
lib
integration
ui
entityselector
projectuserprovider.php
Создано системой
1.10.0