Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
discussionsfilter.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Helper\UI\Discussions
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
use
Bitrix\Main\UI\Filter\DateType
;
7
use
Bitrix\Main\Loader
;
8
use
Bitrix\Main\ModuleManager
;
9
use
Bitrix\Socialnetwork\ComponentHelper
;
10
use
Bitrix\Socialnetwork\Livefeed\RenderParts\User
;
11
use CExtranet;
12
use CLists;
13
use CModule;
14
use CSocNetLogComponent;
15
16
abstract
class
DiscussionsFilter
17
{
18
private
int
$groupId;
19
private
const
LIVEFEED_CODE =
'LIVEFEED'
;
20
public
const
POPUP_OFFSET_LEFT
= 13;
21
22
public
function
__construct
(?
int
$groupId)
23
{
24
$this->groupId = $groupId ?? 0;
25
}
26
27
public
function
getContainerId
(): string
28
{
29
return
$this->groupId === 0 ? self::LIVEFEED_CODE : self::LIVEFEED_CODE .
'_SG'
. $this->groupId;
30
}
31
32
public
function
getFilter
(): array
33
{
34
$filter = [
35
[
36
'id'
=>
'DATE_CREATE'
,
37
'name'
=>
Loc::getMessage
(
'SONET_FILTER_DATE_CREATE'
),
38
'type'
=>
'date'
,
39
'default'
=>
true
,
40
'exclude'
=> [
41
DateType::TOMORROW,
42
DateType::NEXT_DAYS,
43
DateType::NEXT_WEEK,
44
DateType::NEXT_MONTH
45
]
46
],
47
[
48
'id'
=>
'EVENT_ID'
,
49
'name'
=>
Loc::getMessage
(
'SONET_FILTER_EVENT_ID'
),
50
'type'
=>
'list'
,
51
'params'
=> [
52
'multiple'
=>
'Y'
,
53
],
54
'items'
=> $this->
getEventIdList
(),
55
'default'
=> true
56
],
57
[
58
'id'
=>
'CREATED_BY_ID'
,
59
'name'
=>
Loc::getMessage
(
'SONET_FILTER_CREATED_BY'
),
60
'default'
=>
true
,
61
'type'
=>
'dest_selector'
,
62
'params'
=> [
63
'apiVersion'
=>
'3'
,
64
'context'
=>
'FEED_FILTER_CREATED_BY'
,
65
'multiple'
=>
'N'
,
66
'contextCode'
=>
'U'
,
67
'enableAll'
=>
'N'
,
68
'enableSonetgroups'
=>
'N'
,
69
'allowEmailInvitation'
=>
'N'
,
70
'allowSearchEmailUsers'
=>
'N'
,
71
'departmentSelectDisable'
=>
'Y'
,
72
],
73
],
74
];
75
76
if
($this->groupId === 0)
77
{
78
$filter[] = [
79
'id'
=>
'TO'
,
80
'name'
=>
Loc::getMessage
(
'SONET_FILTER_TO'
),
81
'default'
=>
true
,
82
'type'
=>
'dest_selector'
,
83
'params'
=> [
84
'apiVersion'
=>
'3'
,
85
'context'
=>
'FEED_FILTER_TO'
,
86
'multiple'
=>
'N'
,
87
'enableAll'
=>
'Y'
,
88
'enableSonetgroups'
=>
'Y'
,
89
'departmentSelectDisable'
=>
'N'
,
90
'allowEmailInvitation'
=>
91
(
92
ModuleManager::isModuleInstalled
(
'mail'
)
93
&&
ModuleManager::isModuleInstalled
(
'intranet'
) ?
'Y'
:
'N'
94
),
95
'allowSearchEmailUsers'
=> ($this->
isExtranetUser
() ?
'N'
:
'Y'
)
96
]
97
];
98
}
99
100
$filter[] = [
101
'id'
=>
'FAVORITES_USER_ID'
,
102
'name'
=>
Loc::getMessage
(
'SONET_FILTER_FAVORITES'
),
103
'type'
=>
'list'
,
104
'items'
=> [
105
'Y'
=>
Loc::getMessage
(
'SONET_FILTER_LIST_YES'
)
106
]
107
];
108
109
$filter[] = [
110
'id'
=>
'TAG'
,
111
'name'
=>
Loc::getMessage
(
'SONET_FILTER_TAG'
),
112
'type'
=>
'string'
113
];
114
115
if
(
ModuleManager::isModuleInstalled
(
'extranet'
))
116
{
117
$filter[] = [
118
'id'
=>
'EXTRANET'
,
119
'name'
=>
Loc::getMessage
(
'SONET_FILTER_EXTRANET'
),
120
'type'
=>
'checkbox'
121
];
122
}
123
124
return
$filter;
125
}
126
127
public
function
getPresets
(?array $paramsForPresets): array
128
{
129
if
(empty($paramsForPresets))
130
{
131
return
[];
132
}
133
134
return
$this->
convertParamsToPresetFilters
($paramsForPresets);
135
}
136
137
protected
function
bizprocIsAvailable
(): bool
138
{
139
$bizprocIsAvailable = (
140
CModule::IncludeModule(
"lists"
)
141
&& CLists::isFeatureEnabled()
142
&&
ModuleManager::isModuleInstalled
(
'intranet'
)
143
&& (
144
!
Loader::includeModule
(
'extranet'
)
145
|| !CExtranet::isExtranetSite()
146
)
147
);
148
149
return
$bizprocIsAvailable;
150
}
151
152
protected
function
isExtranetUser
(): bool
153
{
154
return
CModule::IncludeModule(
"extranet"
) && !CExtranet::IsIntranetUser();
155
}
156
157
protected
function
getEventIdList
(): array
158
{
159
$eventIdList = [];
160
if
(
ModuleManager::isModuleInstalled
(
'blog'
))
161
{
162
$eventIdList[
'blog_post'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_BLOG_POST'
);
163
$eventIdList[
'blog_post_important'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_BLOG_POST_IMPORTANT'
);
164
if
(
ModuleManager::isModuleInstalled
(
'intranet'
))
165
{
166
$eventIdList[
'blog_post_grat'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_BLOG_POST_GRAT'
);
167
}
168
if
(
ModuleManager::isModuleInstalled
(
'vote'
))
169
{
170
$eventIdList[
'blog_post_vote'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_BLOG_POST_VOTE'
);
171
}
172
}
173
174
if
(
ModuleManager::isModuleInstalled
(
'forum'
))
175
{
176
$eventIdList[
'forum'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_FORUM'
);
177
}
178
179
if
(
180
ComponentHelper::checkLivefeedTasksAllowed
()
181
&&
ModuleManager::isModuleInstalled
(
'tasks'
)
182
)
183
{
184
$eventIdList[
'tasks'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_TASK'
);
185
}
186
187
if
(
ModuleManager::isModuleInstalled
(
'timeman'
))
188
{
189
$eventIdList[
'timeman_entry'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_TIMEMAN_ENTRY'
);
190
$eventIdList[
'report'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_REPORT'
);
191
}
192
193
if
(
ModuleManager::isModuleInstalled
(
'calendar'
))
194
{
195
$eventIdList[
'calendar'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_CALENDAR'
);
196
}
197
198
if
(
ModuleManager::isModuleInstalled
(
'xdimport'
))
199
{
200
$eventIdList[
'data'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_DATA'
);
201
}
202
203
if
(
ModuleManager::isModuleInstalled
(
'photogallery'
))
204
{
205
$eventIdList[
'photo'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_PHOTO'
);
206
}
207
208
if
(
ModuleManager::isModuleInstalled
(
'wiki'
))
209
{
210
$eventIdList[
'wiki'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_WIKI'
);
211
}
212
213
if
($this->
bizprocIsAvailable
())
214
{
215
$eventIdList[
'lists_new_element'
] =
Loc::getMessage
(
'SONET_FILTER_EVENT_ID_BP'
);
216
}
217
218
return
$eventIdList;
219
}
220
221
abstract
public
function
getParamsForPresets
(): array;
222
223
protected
function
convertParamsToPresetFilters
(array $paramsFilters): array
224
{
225
if
(empty($paramsFilters))
226
{
227
return
[];
228
}
229
230
usort($paramsFilters,
static
fn($a, $b) => ($a[
"SORT"
] - $b[
"SORT"
]));
231
232
$paramsFilters = CSocNetLogComponent::ConvertPresetToFilters(
233
$paramsFilters,
234
$this->groupId
235
);
236
237
$presetFilters = [];
238
foreach
($paramsFilters as $filter)
239
{
240
$skipPreset =
false
;
241
$newFilter = $filter[
"FILTER"
];
242
if
(!empty($newFilter[
'EXACT_EVENT_ID'
]))
243
{
244
$newFilter[
'EVENT_ID'
] = [$newFilter[
'EXACT_EVENT_ID'
]];
245
unset($newFilter[
'EXACT_EVENT_ID'
]);
246
}
247
if
(!empty($newFilter[
'CREATED_BY_ID'
]))
248
{
249
$renderPartsUser =
new
User
([
'skipLink'
=>
true
]);
250
if
($renderData = $renderPartsUser->getData($newFilter[
'CREATED_BY_ID'
]))
251
{
252
$newFilter[
'CREATED_BY_ID_label'
] = $renderData[
'name'
];
253
}
254
$newFilter[
'CREATED_BY_ID'
] =
'U'
.$newFilter[
'CREATED_BY_ID'
];
255
}
256
if
(!empty($filter[
'ID'
]))
257
{
258
if
($filter[
'ID'
] ===
'extranet'
)
259
{
260
$newFilter = [
'EXTRANET'
=>
'Y'
];
261
}
262
elseif (
263
$filter[
'ID'
] ===
'bizproc'
264
&& !$this->
bizprocIsAvailable
()
265
)
266
{
267
$skipPreset =
true
;
268
}
269
}
270
271
if
(!$skipPreset)
272
{
273
$presetFilters[$filter[
"ID"
]] = [
274
"name"
=> $filter[
"NAME"
],
275
"fields"
=> $newFilter,
276
"disallow_for_all"
=> ($filter[
"ID"
] ===
"my"
)
277
];
278
}
279
}
280
281
return
$presetFilters;
282
}
283
}
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Definition
loader.php:69
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Main\ModuleManager\isModuleInstalled
static isModuleInstalled($moduleName)
Definition
modulemanager.php:67
Bitrix\Main\UI\Filter\DateType
Definition
datetype.php:11
Bitrix\Socialnetwork\ComponentHelper
Definition
componenthelper.php:32
Bitrix\Socialnetwork\ComponentHelper\checkLivefeedTasksAllowed
static checkLivefeedTasksAllowed()
Definition
componenthelper.php:4994
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter
Definition
discussionsfilter.php:17
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\getContainerId
getContainerId()
Definition
discussionsfilter.php:27
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\getFilter
getFilter()
Definition
discussionsfilter.php:32
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\POPUP_OFFSET_LEFT
const POPUP_OFFSET_LEFT
Definition
discussionsfilter.php:20
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\convertParamsToPresetFilters
convertParamsToPresetFilters(array $paramsFilters)
Definition
discussionsfilter.php:223
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\__construct
__construct(?int $groupId)
Definition
discussionsfilter.php:22
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\bizprocIsAvailable
bizprocIsAvailable()
Definition
discussionsfilter.php:137
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\getPresets
getPresets(?array $paramsForPresets)
Definition
discussionsfilter.php:127
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\getEventIdList
getEventIdList()
Definition
discussionsfilter.php:157
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\getParamsForPresets
getParamsForPresets()
Bitrix\Socialnetwork\Helper\UI\Discussions\DiscussionsFilter\isExtranetUser
isExtranetUser()
Definition
discussionsfilter.php:152
Bitrix\Socialnetwork\Livefeed\RenderParts\User
Definition
user.php:11
Bitrix\Socialnetwork\Helper\UI\Discussions
Definition
discussionsfilter.php:3
modules
socialnetwork
lib
helper
ui
discussions
discussionsfilter.php
Создано системой
1.10.0