Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
usertogroup.php
1<?php
2
10
15
32class 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 {
66 }
67
73 public static function getRolesMember(): array
74 {
76 }
77
83 public static function getInitiatedByAll(): array
84 {
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}
static getGroupModerators(int $groupId)
static update($primary, array $data)