Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
usertogroup.php
1
<?php
2
9
namespace
Bitrix\Socialnetwork
;
10
11
use
Bitrix\Main\Entity
;
12
use
Bitrix\Main\ModuleManager
;
13
use
Bitrix\Main\NotImplementedException
;
14
use
Bitrix\Main\ORM\Query\Join
;
15
32
class
UserToGroupTable
extends
Entity\DataManager
33
{
34
public
const
ROLE_OWNER
= SONET_ROLES_OWNER;
35
public
const
ROLE_MODERATOR
= SONET_ROLES_MODERATOR;
36
public
const
ROLE_USER
= SONET_ROLES_USER;
37
public
const
ROLE_BAN
= SONET_ROLES_BAN;
38
public
const
ROLE_REQUEST
= SONET_ROLES_REQUEST;
39
40
public
const
INITIATED_BY_USER
= SONET_INITIATED_BY_USER;
41
public
const
INITIATED_BY_GROUP
= SONET_INITIATED_BY_GROUP;
42
48
public
static
function
getTableName
(): string
49
{
50
return
'b_sonet_user2group'
;
51
}
52
53
public
static
function
getUfId
(): string
54
{
55
return
'USER_TO_WORKGROUP'
;
56
}
57
63
public
static
function
getRolesAll
(): array
64
{
65
return
[
self::ROLE_OWNER
,
self::ROLE_MODERATOR
,
self::ROLE_USER
,
self::ROLE_BAN
,
self::ROLE_REQUEST
];
66
}
67
73
public
static
function
getRolesMember
(): array
74
{
75
return
[
self::ROLE_OWNER
,
self::ROLE_MODERATOR
,
self::ROLE_USER
];
76
}
77
83
public
static
function
getInitiatedByAll
(): array
84
{
85
return
[
self::INITIATED_BY_USER
,
self::INITIATED_BY_GROUP
];
86
}
87
91
public
static
function
getMap
(): array
92
{
93
return
array(
94
'ID'
=> array(
95
'data_type'
=>
'integer'
,
96
'primary'
=>
true
,
97
'autocomplete'
=>
true
,
98
),
99
'USER_ID'
=> array(
100
'data_type'
=>
'integer'
,
101
),
102
'USER'
=> array(
103
'data_type'
=> (ModuleManager::isModuleInstalled(
'intranet'
) ?
'Bitrix\Intranet\UserTable'
:
'Bitrix\Main\UserTable'
),
104
'reference'
=> array(
'=this.USER_ID'
=>
'ref.ID'
),
105
'join_type'
=> Join::TYPE_INNER,
106
),
107
'GROUP_ID'
=> array(
108
'data_type'
=>
'integer'
,
109
),
110
'GROUP'
=> array(
111
'data_type'
=>
'Bitrix\Socialnetwork\WorkgroupTable'
,
112
'reference'
=> array(
'=this.GROUP_ID'
=>
'ref.ID'
),
113
'join_type'
=> Join::TYPE_INNER,
114
),
115
'ROLE'
=> array(
116
'data_type'
=>
'enum'
,
117
'values'
=> array(self::ROLE_OWNER, self::ROLE_MODERATOR, self::ROLE_USER, self::ROLE_BAN, self::ROLE_REQUEST),
118
),
119
'AUTO_MEMBER'
=> array(
120
'data_type'
=>
'boolean'
,
121
'values'
=> array(
'N'
,
'Y'
)
122
),
123
'DATE_CREATE'
=> array(
124
'data_type'
=>
'datetime'
125
),
126
'DATE_UPDATE'
=> array(
127
'data_type'
=>
'datetime'
128
),
129
'INITIATED_BY_TYPE'
=> array(
130
'data_type'
=>
'enum'
,
131
'values'
=> array(self::INITIATED_BY_USER, self::INITIATED_BY_GROUP),
132
),
133
'INITIATED_BY_USER_ID'
=> array(
134
'data_type'
=>
'integer'
,
135
),
136
'INITIATED_BY_USER'
=> array(
137
'data_type'
=>
'Bitrix\Main\UserTable'
,
138
'reference'
=> array(
'=this.INITIATED_BY_USER_ID'
=>
'ref.ID'
),
139
),
140
'MESSAGE'
=> array(
141
'data_type'
=>
'text'
,
142
)
143
);
144
}
145
155
public
static
function
add
(array $data)
156
{
157
throw
new
NotImplementedException
(
"Use CSocNetUserToGroup class."
);
158
}
159
170
public
static
function
update
($primary, array $data)
171
{
172
throw
new
NotImplementedException
(
"Use CSocNetUserToGroup class."
);
173
}
174
184
public
static
function
delete
($primary)
185
{
186
throw
new
NotImplementedException
(
"Use CSocNetUserToGroup class."
);
187
}
188
189
public
static
function
getGroupModerators
(
int
$groupId): array
190
{
191
$query = UserToGroupTable::query()
192
->setDistinct()
193
->setSelect([
'USER_ID'
])
194
->where(
'GROUP_ID'
,
'='
, $groupId)
195
->where(
'ROLE'
,
'<='
,
UserToGroupTable::ROLE_MODERATOR
)
196
->exec();
197
198
return
$query->fetchAll() ?? [];
199
}
200
}
Bitrix\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Main\NotImplementedException
Definition
exception.php:147
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Query\Join
Definition
join.php:19
Bitrix\Socialnetwork\UserToGroupTable
Definition
usertogroup.php:33
Bitrix\Socialnetwork\UserToGroupTable\getRolesAll
static getRolesAll()
Definition
usertogroup.php:63
Bitrix\Socialnetwork\UserToGroupTable\getMap
static getMap()
Definition
usertogroup.php:91
Bitrix\Socialnetwork\UserToGroupTable\getInitiatedByAll
static getInitiatedByAll()
Definition
usertogroup.php:83
Bitrix\Socialnetwork\UserToGroupTable\getUfId
static getUfId()
Definition
usertogroup.php:53
Bitrix\Socialnetwork\UserToGroupTable\getGroupModerators
static getGroupModerators(int $groupId)
Definition
usertogroup.php:189
Bitrix\Socialnetwork\UserToGroupTable\ROLE_USER
const ROLE_USER
Definition
usertogroup.php:36
Bitrix\Socialnetwork\UserToGroupTable\ROLE_BAN
const ROLE_BAN
Definition
usertogroup.php:37
Bitrix\Socialnetwork\UserToGroupTable\ROLE_REQUEST
const ROLE_REQUEST
Definition
usertogroup.php:38
Bitrix\Socialnetwork\UserToGroupTable\add
static add(array $data)
Definition
usertogroup.php:155
Bitrix\Socialnetwork\UserToGroupTable\INITIATED_BY_GROUP
const INITIATED_BY_GROUP
Definition
usertogroup.php:41
Bitrix\Socialnetwork\UserToGroupTable\INITIATED_BY_USER
const INITIATED_BY_USER
Definition
usertogroup.php:40
Bitrix\Socialnetwork\UserToGroupTable\ROLE_MODERATOR
const ROLE_MODERATOR
Definition
usertogroup.php:35
Bitrix\Socialnetwork\UserToGroupTable\getRolesMember
static getRolesMember()
Definition
usertogroup.php:73
Bitrix\Socialnetwork\UserToGroupTable\ROLE_OWNER
const ROLE_OWNER
Definition
usertogroup.php:34
Bitrix\Socialnetwork\UserToGroupTable\update
static update($primary, array $data)
Definition
usertogroup.php:170
Bitrix\Socialnetwork\UserToGroupTable\getTableName
static getTableName()
Definition
usertogroup.php:48
Bitrix\Socialnetwork
modules
socialnetwork
lib
usertogroup.php
Создано системой
1.10.0