Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
projects.php
1<?
3
5
7{
8 public function getData($params = array())
9 {
10 $result = array(
11 'ITEMS' => array(),
12 'ITEMS_LAST' => array(),
13 'ITEMS_HIDDEN' => array(),
14 'ADDITIONAL_INFO' => array(
15 'SORT_SELECTED' => 300
16 )
17 );
18
20
21 $options = (!empty($params['options']) ? $params['options'] : array());
22
23 $lastItems = (!empty($params['lastItems']) ? $params['lastItems'] : array());
24 $selectedItems = (!empty($params['selectedItems']) ? $params['selectedItems'] : array());
25
26 $limitReached = false;
27 $projectsList = \Bitrix\Socialnetwork\ComponentHelper::getSonetGroupAvailable(array(
28 'limit' => 100,
29 'useProjects' => 'Y'
30 ), $limitReached);
31
32 $projectsList = $projectsList['PROJECTS'];
33
34 $result['ADDITIONAL_INFO']['LIMITED'] = ($limitReached ? 'Y' : 'N');
35
36 $lastProjectsList = array();
37 if(!empty($lastItems[$entityType]))
38 {
39 $result["ITEMS_LAST"] = array_values($lastItems[$entityType]);
40 foreach ($lastItems[$entityType] as $value)
41 {
42 $lastProjectsList[] = str_replace('SG', '', $value);
43 }
44 }
45
46 $selectedProjectsList = array();
47 if(!empty($selectedItems[Handler::ENTITY_TYPE_SONETGROUPS]))
48 {
49 foreach ($selectedItems[Handler::ENTITY_TYPE_SONETGROUPS] as $value)
50 {
51 $selectedProjectsList[] = str_replace('SG', '', $value);
52 }
53 }
54
55 if (!empty($lastProjectsList))
56 {
57 $filter = array(
58 'features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post")),
59 'id' => $lastProjectsList,
60 'useProjects' => 'Y'
61 );
62 if (!empty($options['siteId']))
63 {
64 $filter['site_id'] = $options['siteId'];
65 }
66 $projectsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
67 if (!empty($projectsAdditionalList))
68 {
69 $projectsAdditionalList = $projectsAdditionalList['PROJECTS'];
70 $projectsList = array_merge($projectsList, $projectsAdditionalList);
71 }
72 }
73 if (!empty($selectedProjectsList))
74 {
75 // available to post
76 $filter = array(
77 'features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post")),
78 'id' => $selectedProjectsList,
79 'useProjects' => 'Y'
80 );
81 if (!empty($options['siteId']))
82 {
83 $filter['site_id'] = $options['siteId'];
84 }
85
86 $projectsAdditionalList = \CSocNetLogDestination::getSocnetGroup($filter);
87 if (!empty($projectsAdditionalList))
88 {
89 $projectsAdditionalList = $projectsAdditionalList['PROJECTS'];
90 $projectsList = array_merge($projectsList, $projectsAdditionalList);
91 }
92 }
93
94 if (!empty($selectedItems[Handler::ENTITY_TYPE_SONETGROUPS]))
95 {
96 $hiddenItemsList = array_diff($selectedItems[Handler::ENTITY_TYPE_SONETGROUPS], array_keys($projectsList));
97 $hiddenItemsList = array_map(function($code) { return preg_replace('/^SG(\d+)$/', '$1', $code); }, $hiddenItemsList);
98
99 if (!empty($hiddenItemsList))
100 {
101 $isCurrentUserModuleAdmin = \CSocNetUser::isCurrentUserModuleAdmin();
102 $res = \Bitrix\Socialnetwork\WorkgroupTable::getList(array(
103 'filter' => array(
104 "@ID" => $hiddenItemsList,
105 'PROJECT' => 'Y'
106 ),
107 'select' => array("ID", "NAME", "DESCRIPTION", "OPENED")
108 ));
109
110 $extranetGroupsIdList = \Bitrix\Socialnetwork\ComponentHelper::getExtranetSonetGroupIdList();
111
112 while($groupFields = $res->fetch())
113 {
114 if (
115 $groupFields['OPENED'] == "Y"
116 || $isCurrentUserModuleAdmin
117 )
118 {
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')
125 );
126 }
127 elseif (
128 $groupFields['VISIBLE'] == "Y"
130 )
131 {
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'),
138 "selectable" => 'N'
139 );
140 }
141 else
142 {
143 $result['ITEMS_HIDDEN'][] = 'SG'.$groupFields["ID"];
144 }
145 }
146 }
147 }
148
149 $result['ITEMS'] = $projectsList;
150
151 return $result;
152 }
153
154 public function getTabList($params = array())
155 {
156 $options = (!empty($params['options']) ? $params['options'] : array());
157
158 return array(
159 array(
160 'id' => 'projects',
161 'name' => Loc::getMessage('MAIN_UI_SELECTOR_TAB_PROJECTS'),
162 'sort' => 29
163 )
164 );
165 }
166
167 public function getItemName($itemCode = '')
168 {
169 return \Bitrix\Socialnetwork\Integration\Main\UISelector\SonetGroups::getWorkgroupName($itemCode);
170 }
171}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29