31 public function getData($params = array())
35 'ITEMS_LAST' => array(),
36 'ITEMS_HIDDEN' => array(),
37 'ADDITIONAL_INFO' => array(
38 'GROUPS_LIST' => array(
39 'sonetgroups' => array(
42 'DESC_LESS_MODE' =>
'Y',
46 'SORT_SELECTED' => 300
52 $options = (!empty($params[
'options']) ? $params[
'options'] : array());
54 $lastItems = (!empty($params[
'lastItems']) ? $params[
'lastItems'] : array());
55 $selectedItems = (!empty($params[
'selectedItems']) ? $params[
'selectedItems'] : array());
57 $limitReached =
false;
61 'useProjects' => (!empty($options[
'enableProjects']) ? $options[
'enableProjects'] :
'N')
64 if (!empty($options[
'siteId']))
66 $filter[
'siteId'] = $options[
'siteId'];
70 !empty($options[
'landing'])
71 && ModuleManager::isModuleInstalled(
'landing')
74 $filter[
'landing'] = $options[
'landing'];
77 $sonetGroupsList = \Bitrix\Socialnetwork\ComponentHelper::getSonetGroupAvailable($filter, $limitReached);
80 !empty($options[
'enableProjects'])
81 && $options[
'enableProjects'] ==
'Y'
84 $sonetGroupsList = $sonetGroupsList[
'SONETGROUPS'];
87 $result[
'ADDITIONAL_INFO'][
'LIMITED'] = ($limitReached ?
'Y' :
'N');
89 $lastSonetGroupsList = array();
90 if(!empty($lastItems[$entityType]))
92 $result[
"ITEMS_LAST"] = array_values($lastItems[$entityType]);
93 foreach ($lastItems[$entityType] as $value)
95 $lastSonetGroupsList[] = str_replace(
'SG',
'', $value);
99 $selectedSonetGroupsList = array();
104 $selectedSonetGroupsList[] = str_replace(
'SG',
'', $value);
108 if (!empty($lastSonetGroupsList))
111 'id' => $lastSonetGroupsList,
112 'useProjects' => (!empty($options[
'enableProjects']) ? $options[
'enableProjects'] :
'N')
115 if (!empty($options[
'feature']))
117 $feature = $options[
'feature'];
118 if (trim($feature) <>
'')
121 if (!empty($operations))
123 $filter[
'features'] = [ $feature, $operations ];
129 !empty($options[
'landing'])
130 && ModuleManager::isModuleInstalled(
'landing')
133 $filter[
'landing'] = $options[
'landing'];
135 if (!empty($options[
'siteId']))
137 $filter[
'site_id'] = $options[
'siteId'];
140 $sonetGroupsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
141 if (!empty($sonetGroupsAdditionalList))
144 !empty($options[
'enableProjects'])
145 && $options[
'enableProjects'] ==
'Y'
148 $sonetGroupsAdditionalList = $sonetGroupsAdditionalList[
'SONETGROUPS'];
151 $sonetGroupsList = array_merge($sonetGroupsList, $sonetGroupsAdditionalList);
155 if (!empty($selectedSonetGroupsList))
158 'id' => $selectedSonetGroupsList,
159 'useProjects' => (!empty($options[
'enableProjects']) ? $options[
'enableProjects'] :
'N')
162 if (!empty($options[
'feature']))
164 $feature = $options[
'feature'];
165 if (trim($feature) <>
'')
168 if (!empty($operations))
170 $filter[
'features'] = [ $feature, $operations ];
176 !empty($options[
'landing'])
177 && ModuleManager::isModuleInstalled(
'landing')
180 $filter[
'landing'] = $options[
'landing'];
182 if (!empty($options[
'siteId']))
184 $filter[
'site_id'] = $options[
'siteId'];
187 $sonetGroupsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
188 if (!empty($sonetGroupsAdditionalList))
191 !empty($options[
'enableProjects'])
192 && $options[
'enableProjects'] ==
'Y'
195 $sonetGroupsAdditionalList = $sonetGroupsAdditionalList[
'SONETGROUPS'];
198 $sonetGroupsList = array_merge($sonetGroupsList, $sonetGroupsAdditionalList);
205 $hiddenItemsList = array_map(
function($code) {
return preg_replace(
'/^SG(\d+)$/',
'$1', $code); }, $hiddenItemsList);
207 if (!empty($hiddenItemsList))
210 "@ID" => $hiddenItemsList
214 !empty($options[
'enableProjects'])
215 && $options[
'enableProjects'] ==
'Y'
218 $filter[
'PROJECT'] =
'N';
221 $isCurrentUserModuleAdmin = \CSocNetUser::isCurrentUserModuleAdmin();
222 $res = \Bitrix\Socialnetwork\WorkgroupTable::getList(array(
224 'select' => array(
"ID",
"NAME",
"DESCRIPTION",
"OPENED",
"VISIBLE")
227 $extranetGroupsIdList = \Bitrix\Socialnetwork\ComponentHelper::getExtranetSonetGroupIdList();
229 while($groupFields = $res->fetch())
233 $groupFields[
'OPENED'] ==
"Y"
234 || $isCurrentUserModuleAdmin
239 $sonetGroupsList[
'SG'.$groupFields[
"ID"]] = array(
240 "id" =>
'SG'.$groupFields[
"ID"],
241 "entityId" => $groupFields[
"ID"],
242 "name" => $groupFields[
"NAME"],
243 "desc" => $groupFields[
"DESCRIPTION"],
244 "isExtranet" => (in_array($groupFields[
"ID"], $extranetGroupsIdList) ?
'Y' :
'N')
248 $groupFields[
'VISIBLE'] ==
"Y"
252 $sonetGroupsList[
'SG'.$groupFields[
"ID"]] = array(
253 "id" =>
'SG'.$groupFields[
"ID"],
254 "entityId" => $groupFields[
"ID"],
255 "name" => $groupFields[
"NAME"],
256 "desc" => $groupFields[
"DESCRIPTION"],
257 "isExtranet" => (in_array($groupFields[
"ID"], $extranetGroupsIdList) ?
'Y' :
'N'),
263 $result[
'ITEMS_HIDDEN'][] =
'SG'.$groupFields[
"ID"];
269 $result[
'ITEMS'] = $sonetGroupsList;
287 public function search($params = array())
291 'ADDITIONAL_INFO' => array()
294 $entityOptions = (!empty($params[
'options']) ? $params[
'options'] : array());
295 $requestFields = (!empty($params[
'requestFields']) ? $params[
'requestFields'] : array());
298 !empty($entityOptions[
'additionalData'])
299 && !empty($entityOptions[
'additionalData'][
'LIMITED'])
300 && $entityOptions[
'additionalData'][
'LIMITED'] =
'Y'
304 "SEARCH" => $requestFields[
'searchString'],
305 "LANDING" => (!empty($entityOptions[
'landing']) && ModuleManager::isModuleInstalled(
'landing') && $entityOptions[
'landing'] ==
'Y' ?
'Y' :
'N')
308 if (!empty($entityOptions[
'feature']))
310 $feature = $entityOptions[
'feature'];
311 if (trim($feature) <>
'')
314 if (!empty($operations))
316 $filter[
'FEATURES'] = [ $feature, $operations ];
321 if (!empty($entityOptions[
'siteId']))
323 $filter[
'SITE_ID'] = $entityOptions[
'siteId'];
325 $result[
"ITEMS"] = \CSocNetLogDestination::searchSonetGroups($filter);
343 preg_match(
'/^SG(\d+)$/i', $itemCode, $matches)
344 && intval($matches[1]) > 0
345 ? intval($matches[1])
351 $res = WorkgroupTable::getList(array(
355 'select' => array(
'VISIBLE',
'NAME')
358 ($workgroupFields = $res->fetch())
359 && ($workgroupFields[
"VISIBLE"] ==
"Y")
360 || (\CSocNetUser::isCurrentUserModuleAdmin(SITE_ID,
false))
363 $result = $workgroupFields[
'NAME'];
368 $res = UserToGroupTable::getList(
371 '=GROUP_ID' => $entityId,
372 '=USER_ID' => $USER->getId()
376 'GROUP_NAME' =>
'GROUP.NAME'
380 if ($relationFields = $res->fetch())
382 $result = $relationFields[
'GROUP_NAME'];