8 public function getData($params = array())
12 'ITEMS_LAST' => array(),
13 'ITEMS_HIDDEN' => array(),
14 'ADDITIONAL_INFO' => array(
15 'SORT_SELECTED' => 300
21 $options = (!empty($params[
'options']) ? $params[
'options'] : array());
23 $lastItems = (!empty($params[
'lastItems']) ? $params[
'lastItems'] : array());
24 $selectedItems = (!empty($params[
'selectedItems']) ? $params[
'selectedItems'] : array());
26 $limitReached =
false;
27 $projectsList = \Bitrix\Socialnetwork\ComponentHelper::getSonetGroupAvailable(array(
32 $projectsList = $projectsList[
'PROJECTS'];
34 $result[
'ADDITIONAL_INFO'][
'LIMITED'] = ($limitReached ?
'Y' :
'N');
36 $lastProjectsList = array();
37 if(!empty($lastItems[$entityType]))
39 $result[
"ITEMS_LAST"] = array_values($lastItems[$entityType]);
40 foreach ($lastItems[$entityType] as $value)
42 $lastProjectsList[] = str_replace(
'SG',
'', $value);
46 $selectedProjectsList = array();
51 $selectedProjectsList[] = str_replace(
'SG',
'', $value);
55 if (!empty($lastProjectsList))
58 'features' => array(
"blog", array(
"premoderate_post",
"moderate_post",
"write_post",
"full_post")),
59 'id' => $lastProjectsList,
62 if (!empty($options[
'siteId']))
64 $filter[
'site_id'] = $options[
'siteId'];
66 $projectsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
67 if (!empty($projectsAdditionalList))
69 $projectsAdditionalList = $projectsAdditionalList[
'PROJECTS'];
70 $projectsList = array_merge($projectsList, $projectsAdditionalList);
73 if (!empty($selectedProjectsList))
77 'features' => array(
"blog", array(
"premoderate_post",
"moderate_post",
"write_post",
"full_post")),
78 'id' => $selectedProjectsList,
81 if (!empty($options[
'siteId']))
83 $filter[
'site_id'] = $options[
'siteId'];
86 $projectsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
87 if (!empty($projectsAdditionalList))
89 $projectsAdditionalList = $projectsAdditionalList[
'PROJECTS'];
90 $projectsList = array_merge($projectsList, $projectsAdditionalList);
97 $hiddenItemsList = array_map(
function($code) {
return preg_replace(
'/^SG(\d+)$/',
'$1', $code); }, $hiddenItemsList);
99 if (!empty($hiddenItemsList))
101 $isCurrentUserModuleAdmin = \CSocNetUser::isCurrentUserModuleAdmin();
102 $res = \Bitrix\Socialnetwork\WorkgroupTable::getList(array(
104 "@ID" => $hiddenItemsList,
107 'select' => array(
"ID",
"NAME",
"DESCRIPTION",
"OPENED")
110 $extranetGroupsIdList = \Bitrix\Socialnetwork\ComponentHelper::getExtranetSonetGroupIdList();
112 while($groupFields = $res->fetch())
115 $groupFields[
'OPENED'] ==
"Y"
116 || $isCurrentUserModuleAdmin
119 $projectsList[
'SG'.$groupFields[
"ID"]] = array(
120 "id" =>
'SG'.$groupFields[
"ID"],
121 "entityId" => $groupFields[
"ID"],
122 "name" => $groupFields[
"NAME"],
123 "desc" => $groupFields[
"DESCRIPTION"],
124 "isExtranet" => (in_array($groupFields[
"ID"], $extranetGroupsIdList) ?
'Y' :
'N')
128 $groupFields[
'VISIBLE'] ==
"Y"
132 $projectsList[
'SG'.$groupFields[
"ID"]] = array(
133 "id" =>
'SG'.$groupFields[
"ID"],
134 "entityId" => $groupFields[
"ID"],
135 "name" => $groupFields[
"NAME"],
136 "desc" => $groupFields[
"DESCRIPTION"],
137 "isExtranet" => (in_array($groupFields[
"ID"], $extranetGroupsIdList) ?
'Y' :
'N'),
143 $result[
'ITEMS_HIDDEN'][] =
'SG'.$groupFields[
"ID"];
149 $result[
'ITEMS'] = $projectsList;