5use \Bitrix\Landing\Role;
6use \Bitrix\Landing\Rights;
7use \Bitrix\Landing\Internals\RightsTable;
8use \Bitrix\Landing\Internals\BindingTable;
31 $res = BindingTable::getList([
36 '=BINDING_TYPE' => self::$bindingType,
37 '=BINDING_ID' => $groupId,
38 '=ENTITY_TYPE' => self::ENTITY_TYPE_SITE,
42 return $res->fetch()[
'ENTITY_ID'] ??
null;
54 if (!\
Bitrix\Main\Loader::includeModule(
'socialnetwork'))
59 foreach ($input as $key => $item)
61 if (isset($item[
'ID']))
63 $sitesTitle[$item[
'ID']] =
'';
70 $res = BindingTable::getList([
73 'GROUP_TITLE' =>
'GROUP.NAME'
76 '=BINDING_TYPE' => self::$bindingType,
77 '=ENTITY_TYPE' => self::ENTITY_TYPE_SITE,
78 '=ENTITY_ID' => array_keys($sitesTitle)
83 'Bitrix\Socialnetwork\WorkgroupTable',
85 '=this.BINDING_ID' =>
'ref.ID'
90 while ($row = $res->fetch())
92 $sitesTitle[$row[
'ENTITY_ID']] = $row[
'GROUP_TITLE'];
96 foreach ($input as $key => &$item)
98 if (isset($item[
'ID']) && $sitesTitle[$item[
'ID']])
100 $item[
'TITLE'] = $sitesTitle[$item[
'ID']];
121 $res = \CTask::getList(
123 [
'MODULE_ID' =>
'landing'],
125 while ($row = $res->fetch())
127 if ($row[
'LETTER'] >
'D')
129 $row[
'NAME'] = str_replace(
'landing_right_',
'', $row[
'NAME']);
130 $tasks[] = $fullData ? $row : $row[
'ID'];
144 static $roleId =
null;
146 if ($roleId !==
null)
151 $res = Role::getList([
156 '=TYPE' => self::ROLE_TYPE
159 if ($row = $res->fetch())
161 $roleId = $row[
'ID'];
166 'XML_ID' =>
'MANAGER',
167 'TYPE' => self::ROLE_TYPE
169 if ($res->isSuccess())
171 $roleId = $res->getId();
180 return (
int) $roleId;
196 if (!$groupRoles && \
Bitrix\Main\Loader::includeModule(
'socialnetwork'))
199 'read' => SONET_ROLES_USER,
200 'edit' => SONET_ROLES_USER,
201 'sett' => SONET_ROLES_USER,
202 'delete' => SONET_ROLES_USER,
206 $res = \CSocNetFeaturesPerms::getList(
209 'FEATURE_ENTITY_ID' => $this->bindingId,
210 'FEATURE_ENTITY_TYPE' => SONET_ENTITY_GROUP,
214 while ($row = $res->fetch())
216 $groupRoles[$row[
'OPERATION_ID']] = $row[
'ROLE'];
220 foreach ($tasks as $task)
222 if (!isset($groupRoles[$task[
'NAME']]))
226 $check = RightsTable::getList([
231 'ENTITY_ID' => $siteId,
233 '=ACCESS_CODE' =>
'SG' . $this->bindingId .
'_' . $groupRoles[$task[
'NAME']],
234 'TASK_ID' => $task[
'ID'],
241 'ENTITY_ID' => $siteId,
243 'TASK_ID' => $task[
'ID'],
244 'ACCESS_CODE' =>
'SG' . $this->bindingId .
'_' . $groupRoles[$task[
'NAME']],
259 $opsToRoles = $this->getOperationsToRolesMap($this->bindingId);
273 $res = RightsTable::getList([
278 'ENTITY_ID' => $siteId,
280 'ACCESS_CODE' =>
'SG' . $this->bindingId .
'_%',
284 while ($row = $res->fetch())
286 RightsTable::delete($row[
'ID'])->isSuccess();
296 private function getOperationsToRolesMap(
int $groupId): array
300 if (!\
Bitrix\Main\Loader::includeModule(
'socialnetwork'))
305 $res = \CSocNetFeaturesPerms::getList(
308 'FEATURE_ENTITY_ID' => $groupId,
309 'FEATURE_ENTITY_TYPE' => SONET_ENTITY_GROUP,
313 while ($row = $res->fetch())
315 $opsToRoles[$row[
'OPERATION_ID']] = $row[
'ROLE'];
addSiteRights(int $siteId, array $groupRoles=[])
static getAccessTasks(bool $fullData=false)
static getSiteIdByGroupId(int $groupId)
static recognizeSiteTitle(array $input)
updateSiteRights(int $siteId)
removeSiteRights($siteId)