Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
group.php
1<?php
3
13
14class Group extends Scope
15{
21 public static function init(array $params = [])
22 {
23 if (!Restriction\Manager::isAllowed('limit_crm_free_knowledge_base_project'))
24 {
25 return;
26 }
27 parent::init($params);
28 Role::setExpectedType(self::$currentScopeId);
29 }
30
35 public static function getPublicationPath()
36 {
37 if (\Bitrix\Landing\Connector\Mobile::isMobileHit())
38 {
39 return '/mobile/knowledge/group/';
40 }
41
42 return '/knowledge/group/';
43 }
44
49 public static function getKeyCode()
50 {
51 return 'CODE';
52 }
53
58 public static function getDomainId()
59 {
60 if (!Manager::isB24())
61 {
62 return Domain::getCurrentId();
63 }
64 return 0;
65 }
66
71 public static function getFilterType()
72 {
73 return self::getCurrentScopeId();
74 }
75
80 public static function getExcludedHooks(): array
81 {
82 return [
83 'B24BUTTON',
84 'COPYRIGHT',
85 'CSSBLOCK',
86 'FAVICON',
87 'GACOUNTER',
88 'GTM',
89 'HEADBLOCK',
90 'METAGOOGLEVERIFICATION',
91 'METAMAIN',
92 'METAROBOTS',
93 'METAYANDEXVERIFICATION',
94 'PIXELFB',
95 'PIXELVK',
96 'ROBOTS',
97 'SETTINGS',
98 'SPEED',
99 'YACOUNTER',
100 'COOKIES'
101 ];
102 }
103
110 public static function getGroupIdBySiteId(int $siteId, bool $checkAccess = false): ?int
111 {
112 $res = BindingTable::getList([
113 'select' => [
114 'BINDING_ID'
115 ],
116 'filter' => [
117 '=ENTITY_TYPE' => BindingTable::ENTITY_TYPE_SITE,
118 '=BINDING_TYPE' => 'G',
119 'ENTITY_ID' => $siteId
120 ]
121 ]);
122 if ($row = $res->fetch())
123 {
124 $groupId = (int) $row['BINDING_ID'];
125 if ($checkAccess && Loader::includeModule('socialnetwork'))
126 {
127 $canRead = \CSocNetFeaturesPerms::CanPerformOperation(
129 SONET_ENTITY_GROUP,
130 $groupId,
132 'read'
133 );
134 if (!$canRead)
135 {
136 return null;
137 }
138 }
139 return $groupId;
140 }
141
142 return null;
143 }
144
151 public static function getOperationsForSite(int $siteId): array
152 {
153 static $cache = [];
154
155 if (!array_key_exists($siteId, $cache))
156 {
157 $groupId = self::getGroupIdBySiteId($siteId) ?: 0;
158 $cache[$siteId] = [
159 'read' => false,//see below
160 'edit' => SocialNetwork::canPerformOperation($groupId, Rights::ACCESS_TYPES['edit']),
161 'sett' => SocialNetwork::canPerformOperation($groupId, Rights::ACCESS_TYPES['sett']),
162 'delete' => SocialNetwork::canPerformOperation($groupId, Rights::ACCESS_TYPES['delete']),
163 ];
164
165 if (array_sum($cache[$siteId]))
166 {
167 $cache[$siteId]['read'] = true;
168 }
169 }
170
171 return $cache[$siteId];
172 }
173}
static canPerformOperation(int $groupId, string $operation)
static getCurrentId()
Definition domain.php:148
static setExpectedType($type)
Definition role.php:545
static getOperationsForSite(int $siteId)
Definition group.php:151
static init(array $params=[])
Definition group.php:21
static getGroupIdBySiteId(int $siteId, bool $checkAccess=false)
Definition group.php:110