Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
param.php
1<?php
2
4
10
11class Param
12{
13 protected $component;
14 protected $request;
15
16 public function __construct($params)
17 {
18 if (!empty($params['component']))
19 {
20 $this->component = $params['component'];
21 }
22
23 if (!empty($params['request']))
24 {
25 $this->request = $params['request'];
26 }
27 else
28 {
29 $this->request = Util::getRequest();
30 }
31 }
32
33 public function getRequest()
34 {
35 return $this->request;
36 }
37
38 public function getComponent()
39 {
40 return $this->component;
41 }
42
43 public function prepareDateFilterParams(&$componentParams): void
44 {
45 $request = $this->getRequest();
46
47 if ($request->get('flt_date_datesel') === null)
48 {
49 $componentParams['LOG_DATE_FROM'] = ($request->get('flt_date_from') <> '' ? trim($request->get('flt_date_from')) : '');
50 $componentParams['LOG_DATE_TO'] = ($request->get('flt_date_to') <> '' ? trim($request->get('flt_date_to')) : '');
51 }
52 elseif ($request->get('flt_date_datesel') <> '')
53 {
54 $day = date('w');
55 if($day == 0)
56 {
57 $day = 7;
58 }
59 switch($request->get('flt_date_datesel'))
60 {
61 case 'today':
62 $componentParams['LOG_DATE_FROM'] = $componentParams['LOG_DATE_TO'] = convertTimeStamp();
63 break;
64 case 'yesterday':
65 $componentParams['LOG_DATE_FROM'] = $componentParams['LOG_DATE_TO'] = convertTimeStamp(time()-86400);
66 break;
67 case 'week':
68 $componentParams['LOG_DATE_FROM'] = convertTimeStamp(time()-($day-1)*86400);
69 $componentParams['LOG_DATE_TO'] = convertTimeStamp(time()+(7-$day)*86400);
70 break;
71 case 'week_ago':
72 $componentParams['LOG_DATE_FROM'] = convertTimeStamp(time()-($day-1+7)*86400);
73 $componentParams['LOG_DATE_TO'] = convertTimeStamp(time()-($day)*86400);
74 break;
75 case 'month':
76 $componentParams['LOG_DATE_FROM'] = convertTimeStamp(mktime(0, 0, 0, date('n'), 1));
77 $componentParams['LOG_DATE_TO'] = convertTimeStamp(mktime(0, 0, 0, date('n')+1, 0));
78 break;
79 case 'month_ago':
80 $componentParams['LOG_DATE_FROM'] = convertTimeStamp(mktime(0, 0, 0, date('n')-1, 1));
81 $componentParams['LOG_DATE_TO'] = convertTimeStamp(mktime(0, 0, 0, date('n'), 0));
82 break;
83 case 'days':
84 $componentParams['LOG_DATE_FROM'] = convertTimeStamp(time() - (int)$request->get('flt_date_days')*86400);
85 $componentParams['LOG_DATE_TO'] = '';
86 break;
87 case 'exact':
88 $componentParams['LOG_DATE_FROM'] = $componentParams['LOG_DATE_TO'] = $request->get('flt_date_from');
89 break;
90 case 'after':
91 $componentParams['LOG_DATE_FROM'] = $request->get('flt_date_from');
92 $componentParams['LOG_DATE_TO'] = '';
93 break;
94 case 'before':
95 $componentParams['LOG_DATE_FROM'] = '';
96 $componentParams['LOG_DATE_TO'] = $request->get('flt_date_to');
97 break;
98 case 'interval':
99 $componentParams['LOG_DATE_FROM'] = $request->get('flt_date_from');
100 $componentParams['LOG_DATE_TO'] = $request->get('flt_date_to');
101 break;
102 }
103 }
104 else
105 {
106 $componentParams['LOG_DATE_FROM'] = $componentParams['LOG_DATE_TO'] = '';
107 }
108 }
109
110 public function prepareRatingParams(&$componentParams): void
111 {
112 \CRatingsComponentsMain::getShowRating($componentParams);
113 if (
114 !isset($componentParams['RATING_TYPE'])
115 || $componentParams['RATING_TYPE'] == ''
116 )
117 {
118 $componentParams['RATING_TYPE'] = Option::get('main', 'rating_vote_template', (Option::get('main', 'rating_vote_type', 'standart') === 'like'? 'like': 'standart'));
119 }
120 switch ($componentParams['RATING_TYPE'])
121 {
122 case 'like_graphic':
123 $componentParams['RATING_TYPE'] = 'like';
124 break;
125 case 'standart':
126 $componentParams['RATING_TYPE'] = 'standart_text';
127 break;
128 default:
129 }
130 }
131
132 public function prepareRequestVarParams(&$componentParams): void
133 {
134 Util::checkEmptyParamString($componentParams, 'USER_VAR', 'user_id');
135 Util::checkEmptyParamString($componentParams, 'GROUP_VAR', 'group_id');
136 Util::checkEmptyParamString($componentParams, 'PAGE_VAR', 'page');
137 }
138
139 public function prepareRequestParams(&$componentParams): void
140 {
141 $request = $this->getRequest();
142
143 Util::checkEmptyParamInteger($componentParams, 'GROUP_ID', 0);
144 if ($componentParams['GROUP_ID'] <= 0)
145 {
146 if (
147 !empty($request->get('TO_CODE'))
148 && !empty($request->get('TO_CODE')['SG'])
149 && is_array($request->get('TO_CODE')['SG'])
150 )
151 {
152 preg_match('/^SG(\d+)$/', $request->get('TO_CODE')['SG'][0], $matches);
153 if (!empty($matches))
154 {
155 $componentParams['GROUP_ID'] = $matches[1];
156 }
157 }
158 elseif (!empty($request->get('flt_group_id')))
159 {
160 $componentParams['GROUP_ID'] = (int)$request->get('flt_group_id');
161 }
162 }
163
164 if (empty($componentParams['DESTINATION']))
165 {
166 $componentParams['DESTINATION'] = [];
167 if (
168 !empty($request->get('TO_CODE'))
169 && is_array($request->get('TO_CODE'))
170 )
171 {
172 foreach($request->get('TO_CODE') as $codeList)
173 {
174 if (is_array($codeList))
175 {
176 foreach($codeList as $code)
177 {
178 $componentParams['DESTINATION'][] = $code;
179 }
180 }
181 }
182 }
183 }
184
185 $componentParams['ENTITY_TYPE'] = '';
186 $componentParams['TO_USER_ID'] = 0;
187
188 if ($componentParams['GROUP_ID'] > 0)
189 {
190 $componentParams['ENTITY_TYPE'] = SONET_ENTITY_GROUP;
191 }
192 elseif (
193 !empty($request->get('TO_CODE'))
194 && is_array($request->get('TO_CODE'))
195 && !empty($request->get('TO_CODE')['U'])
196 && is_array($request->get('TO_CODE')['U'])
197 )
198 {
199 preg_match('/^U(\d+)$/', $request->get('TO_CODE')['U'][0], $matches);
200 if (!empty($matches))
201 {
202 $componentParams['TO_USER_ID'] = (int)$matches[1];
203 }
204 }
205 else
206 {
207 $componentParams['TO_USER_ID'] = (int)$request->get('flt_to_user_id');
208 }
209
210 if (
211 $componentParams['ENTITY_TYPE'] == ''
212 && $request->get('flt_entity_type') <> ''
213 )
214 {
215 $componentParams['ENTITY_TYPE'] = trim($request->get('flt_entity_type'));
216 }
217
218 Util::checkEmptyParamInteger($componentParams, 'USER_ID', 0);
219 if (
220 $componentParams['USER_ID'] <= 0
221 && !empty($request->get('flt_user_id'))
222 )
223 {
224 $componentParams['USER_ID'] = (int)$request->get('flt_user_id');
225 }
226
227 $componentParams['CREATED_BY_ID'] = 0;
228
229 if (
230 !empty($request->get('CREATED_BY_CODE'))
231 && is_array($request->get('CREATED_BY_CODE'))
232 && !empty($request->get('CREATED_BY_CODE')['U'])
233 && is_array($request->get('CREATED_BY_CODE')['U'])
234 )
235 {
236 preg_match('/^U(\d+)$/', $request->get('CREATED_BY_CODE')['U'][0], $matches);
237 if (!empty($matches))
238 {
239 $componentParams['CREATED_BY_ID'] = (int)$matches[1];
240 }
241 }
242 elseif (!empty($request->get('flt_created_by_id')))
243 {
244 $createdByIdValue = $request->get('flt_created_by_id');
245 if (is_array($createdByIdValue))
246 {
247 $createdByIdValue = $createdByIdValue[0];
248 }
249
250 if (!is_array($createdByIdValue))
251 {
252 if (preg_match('/^(\d+)$/', $createdByIdValue, $matches))
253 {
254 $componentParams['CREATED_BY_ID'] = $createdByIdValue;
255 }
256 else
257 {
258 $userList = \CSocNetUser::searchUser($createdByIdValue, false);
259 if (
260 is_array($userList)
261 && !empty($userList)
262 )
263 {
264 $componentParams['CREATED_BY_ID'] = key($userList);
265 }
266 }
267 }
268 }
269
270 $componentParams['TAG'] = ($request->get('TAG') ? trim($request->get('TAG')) : '');
271 $componentParams['FIND'] = ($request->get('FIND') ? trim($request->get('FIND')) : '');
272 }
273
274 public function prepareCommentsParams(&$componentParams): void
275 {
276 $componentParams['USE_COMMENTS'] = ($componentParams['USE_COMMENTS'] ?? 'N');
277 Util::checkEmptyParamInteger($componentParams, 'COMMENTS_IN_EVENT', 3);
278 }
279
280 public function prepareDestinationParams(&$componentParams): void
281 {
282 Util::checkEmptyParamInteger($componentParams, 'DESTINATION_LIMIT', 100);
283 Util::checkEmptyParamInteger($componentParams, 'DESTINATION_LIMIT_SHOW', 3);
284 }
285
286 public function prepareCommentPropertyParams(&$componentParams): void
287 {
288 $componentParams['COMMENT_PROPERTY'] = [ 'UF_SONET_COM_FILE', 'UF_SONET_COM_URL_PRV' ];
289 if (
290 ModuleManager::isModuleInstalled('webdav')
291 || ModuleManager::isModuleInstalled('disk')
292 )
293 {
294 $componentParams['COMMENT_PROPERTY'][] = 'UF_SONET_COM_DOC';
295 }
296 }
297
298 public function prepareDateTimeFormatParams(&$componentParams): void
299 {
300 \CSocNetLogComponent::processDateTimeFormatParams($componentParams);
301 }
302
303 public function prepareCounterParams(&$componentParams): void
304 {
305 $request = $this->getRequest();
306
307 $componentParams['SET_LOG_COUNTER'] = (
308 $componentParams['SHOW_UNREAD'] === 'Y'
309 && (
310 empty($request->get('logajax'))
311 || $request->get('RELOAD') === 'Y'
312 )
313 && (
314 empty($request->get('action'))
315 || $request->get('action') !== 'SBPE_get_full_form'
316 )
317 && (
318 empty($request->get('startVideoRecorder'))
319 || $request->get('startVideoRecorder') !== 'Y'
320 )
321 ? 'Y'
322 : 'N'
323 );
324 }
325
326 public function preparePageParams(&$componentParams): void
327 {
328 $componentParams['SET_LOG_PAGE_CACHE'] = (
329 $componentParams['LOG_ID'] <= 0
330 && $componentParams['MODE'] !== 'LANDING'
331 ? 'Y'
332 : 'N'
333 );
334 }
335
336 public function prepareParentParams(&$componentParams): void
337 {
338 $parentParams = $this->getComponent()->getParent()->arParams;
339
340 Util::checkEmptyParamInteger($componentParams, 'BLOG_IMAGE_MAX_WIDTH', (int) ($parentParams['BLOG_IMAGE_MAX_WIDTH'] ?? 0));
341 Util::checkEmptyParamInteger($componentParams, 'BLOG_IMAGE_MAX_HEIGHT', (int) ($parentParams['BLOG_IMAGE_MAX_HEIGHT'] ?? 0));
342 Util::checkEmptyParamString($componentParams, 'BLOG_COMMENT_ALLOW_IMAGE_UPLOAD', trim($parentParams['BLOG_COMMENT_ALLOW_IMAGE_UPLOAD'] ?? ''));
343 Util::checkEmptyParamString($componentParams, 'BLOG_ALLOW_POST_CODE', trim($parentParams['BLOG_ALLOW_POST_CODE'] ?? ''));
344 Util::checkEmptyParamString($componentParams, 'BLOG_COMMENT_ALLOW_VIDEO', trim($parentParams['BLOG_COMMENT_ALLOW_VIDEO'] ?? ''));
345
346 $componentParams['BLOG_GROUP_ID'] = (int) ($parentParams['BLOG_GROUP_ID'] ?? null);
347 $componentParams['BLOG_USE_CUT'] = (isset($parentParams['BLOG_USE_CUT']) ? trim($parentParams['BLOG_USE_CUT']) : (isset($componentParams['BLOG_USE_CUT']) ? trim($componentParams['BLOG_USE_CUT']) : ''));
348 $componentParams['PHOTO_USER_IBLOCK_TYPE'] = trim($parentParams['PHOTO_USER_IBLOCK_TYPE'] ?? '');
349 $componentParams['PHOTO_USER_IBLOCK_ID'] = (int) ($parentParams['PHOTO_USER_IBLOCK_ID'] ?? 0);
350 $componentParams['PHOTO_GROUP_IBLOCK_TYPE'] = trim($parentParams['PHOTO_GROUP_IBLOCK_TYPE'] ?? '');
351 $componentParams['PHOTO_GROUP_IBLOCK_ID'] = (int) ($parentParams['PHOTO_GROUP_IBLOCK_ID'] ?? 0);
352 $componentParams['PHOTO_MAX_VOTE'] = (int) ($parentParams['PHOTO_MAX_VOTE'] ?? 0);
353 $componentParams['PHOTO_USE_COMMENTS'] = trim($parentParams['PHOTO_USE_COMMENTS'] ?? '');
354 $componentParams['PHOTO_COMMENTS_TYPE'] = trim($parentParams['PHOTO_COMMENTS_TYPE'] ?? '');
355 $componentParams['PHOTO_FORUM_ID'] = (int) ($parentParams['PHOTO_FORUM_ID'] ?? 0);
356 $componentParams['PHOTO_BLOG_URL'] = trim($parentParams['PHOTO_BLOG_URL'] ?? '');
357 $componentParams['PHOTO_USE_CAPTCHA'] = trim($parentParams['PHOTO_USE_CAPTCHA'] ?? '');
358 $componentParams['PHOTO_COUNT'] = (int) ($parentParams['LOG_PHOTO_COUNT'] ?? 0);
359 $componentParams['PHOTO_THUMBNAIL_SIZE'] = (int) ($parentParams['LOG_PHOTO_THUMBNAIL_SIZE'] ?? 0);
360 $componentParams['FORUM_ID'] = (int) ($parentParams['FORUM_ID'] ?? 0);
361 }
362
363 public function prepareParent2Params(&$componentParams): void
364 {
365 $parent2Params = $this->getComponent()->getParent()->getParent()->arParams;
366
367 Util::checkEmptyParamInteger($componentParams, 'BLOG_IMAGE_MAX_WIDTH', (int) ($parent2Params['BLOG_IMAGE_MAX_WIDTH'] ?? 0));
368 Util::checkEmptyParamInteger($componentParams, 'BLOG_IMAGE_MAX_HEIGHT', (int) ($parent2Params['BLOG_IMAGE_MAX_HEIGHT'] ?? 0));
369 Util::checkEmptyParamString($componentParams, 'BLOG_COMMENT_ALLOW_IMAGE_UPLOAD', trim($parent2Params['BLOG_COMMENT_ALLOW_IMAGE_UPLOAD'] ?? ''));
370 Util::checkEmptyParamString($componentParams, 'BLOG_ALLOW_POST_CODE', trim($parent2Params['BLOG_ALLOW_POST_CODE'] ?? ''));
371 Util::checkEmptyParamString($componentParams, 'BLOG_COMMENT_ALLOW_VIDEO', trim($parent2Params['BLOG_COMMENT_ALLOW_VIDEO'] ?? ''));
372 Util::checkEmptyParamInteger($componentParams, 'BLOG_GROUP_ID', (int) ($parent2Params['BLOG_GROUP_ID'] ?? 0));
373 Util::checkEmptyParamString($componentParams, 'PHOTO_USER_IBLOCK_TYPE', trim($parent2Params['PHOTO_USER_IBLOCK_TYPE'] ?? ''));
374 Util::checkEmptyParamInteger($componentParams, 'PHOTO_USER_IBLOCK_ID', (int) ($parent2Params['PHOTO_USER_IBLOCK_ID'] ?? 0));
375 Util::checkEmptyParamString($componentParams, 'PHOTO_GROUP_IBLOCK_TYPE', trim($parent2Params['PHOTO_GROUP_IBLOCK_TYPE'] ?? ''));
376 Util::checkEmptyParamInteger($componentParams, 'PHOTO_GROUP_IBLOCK_ID', (int) ($parent2Params['PHOTO_GROUP_IBLOCK_ID'] ?? 0));
377 Util::checkEmptyParamInteger($componentParams, 'PHOTO_MAX_VOTE', (int) ($parent2Params['PHOTO_MAX_VOTE'] ?? 0));
378 Util::checkEmptyParamString($componentParams, 'PHOTO_USE_COMMENTS', trim($parent2Params['PHOTO_USE_COMMENTS'] ?? ''));
379 Util::checkEmptyParamString($componentParams, 'PHOTO_COMMENTS_TYPE', trim($parent2Params['PHOTO_COMMENTS_TYPE'] ?? ''));
380 Util::checkEmptyParamInteger($componentParams, 'PHOTO_FORUM_ID', (int) ($parent2Params['PHOTO_FORUM_ID'] ?? 0));
381 Util::checkEmptyParamString($componentParams, 'PHOTO_BLOG_URL', trim($parent2Params['PHOTO_BLOG_URL'] ?? ''));
382 Util::checkEmptyParamString($componentParams, 'PHOTO_USE_CAPTCHA', trim($parent2Params['PHOTO_USE_CAPTCHA'] ?? ''));
383 Util::checkEmptyParamInteger($componentParams, 'PHOTO_COUNT', (int) ($parent2Params['LOG_PHOTO_COUNT'] ?? 0));
384 Util::checkEmptyParamInteger($componentParams, 'PHOTO_THUMBNAIL_SIZE', (int) ($parent2Params['LOG_PHOTO_THUMBNAIL_SIZE'] ?? 0));
385 Util::checkEmptyParamInteger($componentParams, 'FORUM_ID', (int) ($parent2Params['FORUM_ID'] ?? 0));
386
387 $componentParams['BLOG_USE_CUT'] = (isset($parent2Params['BLOG_USE_CUT']) ? trim($parent2Params['BLOG_USE_CUT']) : (isset($componentParams['BLOG_USE_CUT']) ? trim($componentParams['BLOG_USE_CUT']) : ''));
388 }
389
390 public function preparePageTitleParams(&$componentParams): void
391 {
392 Util::checkEmptyParamString($componentParams, 'SET_TITLE', 'N');
393 Util::checkEmptyParamString($componentParams, 'SET_NAV_CHAIN', '');
394 }
395
396 public function prepareBehaviourParams(&$componentParams): void
397 {
398 global $USER;
399
400 if (
401 $componentParams['AUTH'] === 'Y'
402 || $USER->isAuthorized()
403 )
404 {
405 $presetFilterId = $this->getComponent()->getPresetFilterIdValue();
406 $presetFilterTopId = $this->getComponent()->getPresetFilterTopIdValue();
407 $request = $this->getRequest();
408
409 if(isset($componentParams['DISPLAY']))
410 {
411 $componentParams['SHOW_UNREAD'] = 'N';
412 $componentParams['SHOW_REFRESH'] = 'N';
413 $componentParams['SHOW_EVENT_ID_FILTER'] = 'N';
414
415 if (
416 $componentParams['DISPLAY'] > 0 // ???
417 || in_array($componentParams['DISPLAY'], [ 'mine', 'forme' ])
418 )
419 {
420 $componentParams['SET_LOG_COUNTER'] = 'N';
421 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
422 }
423 elseif ($componentParams['DISPLAY'] === 'my')
424 {
425 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
426 }
427 }
428
429 if (empty($componentParams['DESTINATION']))
430 {
431 if (
432 ($componentParams['GROUP_ID'] > 0 && !$this->isSpace($componentParams))
433 || !$this->isSmartTrackingMode($componentParams)
434 )
435 {
436 $componentParams['SET_LOG_PAGE_CACHE'] = 'Y';
437 $componentParams['USE_FOLLOW'] = 'N';
438 }
439 elseif ($componentParams['TO_USER_ID'] > 0)
440 {
441 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
442 $componentParams['USE_FOLLOW'] = 'N';
443 }
444 elseif (
445 $componentParams['TAG'] <> ''
446 || $componentParams['FIND'] <> ''
447 )
448 {
449 $componentParams['SET_LOG_COUNTER'] = 'N';
450 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
451 $componentParams['SHOW_UNREAD'] = 'N';
452 $componentParams['USE_FOLLOW'] = 'N';
453 }
454 }
455
456 if (
457 (
458 isset($componentParams['!EXACT_EVENT_ID'])
459 && $componentParams['!EXACT_EVENT_ID'] <> ''
460 )
461 || (
462 isset($componentParams['EXACT_EVENT_ID'])
463 && $componentParams['EXACT_EVENT_ID'] <> ''
464 )
465 || (
466 isset($componentParams['EVENT_ID'])
467 && !is_array($componentParams['EVENT_ID'])
468 && $componentParams['EVENT_ID'] <> ''
469 )
470 || $presetFilterId === 'extranet'
471 || $componentParams['CREATED_BY_ID'] > 0
472 || (
473 isset($componentParams['EVENT_ID'])
474 && is_array($componentParams['EVENT_ID'])
475 && !in_array('all', $componentParams['EVENT_ID'], true)
476 )
477 || (
478 isset($componentParams['LOG_DATE_FROM'])
479 && $componentParams['LOG_DATE_FROM'] <> ''
480 && makeTimeStamp($componentParams['LOG_DATE_FROM'], \CSite::getDateFormat('SHORT')) < time() + \CTimeZone::getOffset()
481 )
482 || (
483 isset($componentParams['LOG_DATE_TO'])
484 && $componentParams['LOG_DATE_TO'] <> ''
485 && makeTimeStamp($componentParams['LOG_DATE_TO'], \CSite::getDateFormat('SHORT')) < time() + \CTimeZone::getOffset()
486 )
487 )
488 {
489 $componentParams['SET_LOG_COUNTER'] = 'N';
490 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
491 $componentParams['SHOW_UNREAD'] = 'N';
492 $componentParams['USE_FOLLOW'] = 'N';
493 }
494
495 if ($componentParams['IS_CRM'] === 'Y')
496 {
497 Util::checkEmptyParamString($componentParams, 'CRM_ENTITY_TYPE', '');
498 Util::checkEmptyParamInteger($componentParams, 'CRM_ENTITY_ID', 0);
499
500 if ($componentParams['CRM_ENTITY_TYPE'] <> '')
501 {
502 $componentParams['SET_LOG_COUNTER'] = 'N';
503 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
504 $componentParams['SHOW_UNREAD'] = 'N';
505 }
506 elseif ($presetFilterTopId)
507 {
508 $componentParams['SET_LOG_COUNTER'] = 'N';
509 $componentParams['SHOW_UNREAD'] = 'N';
510 }
511 $componentParams['CRM_EXTENDED_MODE'] = (isset($componentParams['CRM_EXTENDED_MODE']) && $componentParams['CRM_EXTENDED_MODE'] === 'Y' ? 'Y' : 'N');
512 }
513
514 if ($componentParams['LOG_CNT'] > 0)
515 {
516 $componentParams['SHOW_NAV_STRING'] = 'N';
517 $componentParams['SHOW_REFRESH'] = 'N';
518 }
519
520 if (
521 (
522 !isset($componentParams['USE_FAVORITES'])
523 || $componentParams['USE_FAVORITES'] !== 'N'
524 )
525 && isset($componentParams['FAVORITES'])
526 && $componentParams['FAVORITES'] === 'Y'
527 )
528 {
529 $componentParams['SET_LOG_COUNTER'] = 'N';
530 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
531 $componentParams['SHOW_UNREAD'] = 'N';
532 }
533
534 if ((int)$request->get('pagesize') > 0)
535 {
536 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
537 }
538 }
539 }
540
541 public function prepareCommentFormParams(&$componentParams): void
542 {
543 $requestParams = $this->getRequest()->getPost('params');
544
545 $componentParams['UID'] = (
546 !empty($requestParams)
547 && is_array($requestParams)
548 && !empty($requestParams['commentFormUID'])
549 ? $requestParams['commentFormUID']
550 : \Bitrix\Main\Security\Random::getString(4)
551 );
552
553 $componentParams['BLOG_UID'] = (
554 !empty($requestParams)
555 && is_array($requestParams)
556 && !empty($requestParams['blogCommentFormUID'])
557 ? $requestParams['blogCommentFormUID']
558 : \Bitrix\Main\Security\Random::getString(4)
559 );
560
561 $componentParams['FORM_ID'] = 'sonetCommentForm' . $componentParams['UID'];
562 $componentParams['BLOG_FORM_ID'] = 'blogCommentForm' . $componentParams['BLOG_UID'];
563 }
564
565 public function processPresetFilterParams(&$componentParams): void
566 {
567 global $USER;
568
569 $request = $this->getRequest();
570
571 $presetFilterTopId = $this->getComponent()->getPresetFilterTopIdValue();
572 $presetFilterId = $this->getComponent()->getPresetFilterIdValue();
573 $commentsNeeded = $this->getComponent()->getCommentsNeededValue();
574
575 if(
576 $request->get('preset_filter_top_id') <> ''
577 && $request->get('preset_filter_top_id') !== 'clearall'
578 )
579 {
580 $presetFilterTopId = $request->get('preset_filter_top_id');
581 }
582 elseif (
583 isset($componentParams['preset_filter_top_id'])
584 && $componentParams['preset_filter_top_id'] <> ''
585 && $componentParams['preset_filter_top_id'] !== 'clearall'
586 ) // from nextPage ajax request
587 {
588 $presetFilterTopId = $componentParams['preset_filter_top_id'];
589 }
590
591 if(
592 $request->get('preset_filter_id') <> ''
593 && $request->get('preset_filter_id') !== 'clearall'
594 )
595 {
596 $presetFilterId = $request->get('preset_filter_id');
597 }
598 elseif (
599 isset($componentParams['preset_filter_id'])
600 && $componentParams['preset_filter_id'] <> ''
601 && $componentParams['preset_filter_id'] !== 'clearall'
602 ) // from nextPage ajax request
603 {
604 $presetFilterId = $componentParams['preset_filter_id'];
605 }
606
607 $presetFiltersOptions = $presetFiltersList = false;
608 if (
609 $componentParams['SHOW_EVENT_ID_FILTER'] !== 'N'
610 && $USER->isAuthorized()
611 )
612 {
613 $presetFiltersOptions = \CUserOptions::getOption('socialnetwork', '~log_filter_'.SITE_ID);
614 if (!is_array($presetFiltersOptions))
615 {
616 $presetFiltersOptions = \CUserOptions::getOption('socialnetwork', '~log_filter');
617 }
618 }
619
620 if (
621 is_array($presetFiltersOptions)
622 && $componentParams['SHOW_EVENT_ID_FILTER'] !== 'N'
623 && $componentParams['IS_CRM'] !== 'Y'
624 )
625 {
626 if($request->get('preset_filter_id') <> '')
627 {
628 \CUserOptions::deleteOption('socialnetwork', '~log_'.$componentParams['ENTITY_TYPE'].'_'.($componentParams['ENTITY_TYPE'] == SONET_ENTITY_GROUP ? $componentParams['GROUP_ID'] : $componentParams['USER_ID']));
629 }
630
631 $presetFiltersList = \CSocNetLogComponent::convertPresetToFilters($presetFiltersOptions, $componentParams['GROUP_ID'] ?? null);
632
633 // to filter component
634 $livefeedFilterHandler = new FilterHandler([
635 'filterItems' => $presetFiltersList
636 ]);
637 AddEventHandler('socialnetwork', 'OnBeforeSonetLogFilterFill', [ $livefeedFilterHandler, 'OnBeforeSonetLogFilterFill' ]);
638 }
639
640 if (
641 $componentParams['IS_CRM'] === 'Y'
642 && isset($componentParams['CRM_ENTITY_TYPE'])
643 && Loader::includeModule('crm')
644 )
645 {
646 $liveFeedFilter = new \CCrmLiveFeedFilter([ 'EntityTypeID' => \CCrmLiveFeedEntity::resolveEntityTypeID($componentParams['CRM_ENTITY_TYPE']) ]);
647 AddEventHandler('socialnetwork', 'OnSonetLogFilterProcess', [ $liveFeedFilter, 'OnSonetLogFilterProcess' ]);
648 }
649
650 $presetTopFiltersList = [];
651 if (!is_array($presetFiltersList))
652 {
653 $presetFiltersList = [];
654 }
655
656 $res = GetModuleEvents('socialnetwork', 'OnSonetLogFilterProcess');
657 while ($eventFields = $res->fetch())
658 {
659 $eventResult = ExecuteModuleEventEx($eventFields, [ $presetFilterTopId, $presetFilterId, $presetTopFiltersList, $presetFiltersList ]);
660 if (is_array($eventResult))
661 {
662 if (isset($eventResult['GET_COMMENTS']))
663 {
664 $commentsNeeded = $eventResult['GET_COMMENTS'];
665 }
666 if (isset($eventResult['PARAMS']) && is_array($eventResult['PARAMS']))
667 {
668 foreach($eventResult['PARAMS'] as $key => $value)
669 {
670 $componentParams[$key] = $value;
671 }
672 }
673 }
674 }
675
676 if ($componentParams['SHOW_EVENT_ID_FILTER'] !== 'N')
677 {
678 $eventResult = \CSocNetLogComponent::onSonetLogFilterProcess($presetFilterTopId, $presetFilterId, $presetTopFiltersList, $presetFiltersList);
679 if (is_array($eventResult))
680 {
681 if (isset($eventResult['GET_COMMENTS']))
682 {
683 $commentsNeeded = $eventResult['GET_COMMENTS'];
684 }
685 if (isset($eventResult['PARAMS']) && is_array($eventResult['PARAMS']))
686 {
687 foreach($eventResult['PARAMS'] as $key => $value)
688 {
689 $componentParams[$key] = $value;
690 }
691 }
692 }
693 }
694
695 $this->getComponent()->setPresetFilterTopIdValue($presetFilterTopId);
696 $this->getComponent()->setPresetFilterIdValue($presetFilterId);
697 $this->getComponent()->setCommentsNeededValue($commentsNeeded);
698 }
699
700 public function prepareFollowParams(&$componentParams): void
701 {
702 global $USER;
703
704 if(
705 (
706 defined('DisableSonetLogFollow')
707 && DisableSonetLogFollow === true
708 )
709 || !$USER->isAuthorized()
710 || (
711 isset($componentParams['DISPLAY'])
712 && in_array($componentParams['DISPLAY'], [ 'my', 'mine', 'forme' ])
713 )
714 )
715 {
716 $componentParams['USE_FOLLOW'] = 'N';
717 }
718 elseif (
719 !isset($componentParams['USE_FOLLOW'])
720 || $componentParams['USE_FOLLOW'] == ''
721 )
722 {
723 $componentParams['USE_FOLLOW'] = 'Y';
724 }
725 }
726
727 public function prepareModeParams(&$componentParams): void
728 {
729 if (
730 !empty($componentParams['PUBLIC_MODE'])
731 && $componentParams['PUBLIC_MODE'] === 'Y'
732 )
733 {
734 $componentParams['MODE'] = 'PUB';
735 }
736
737 if (!empty($componentParams['MODE']))
738 {
739 if ($componentParams['MODE'] === 'LANDING')
740 {
741 $componentParams['HIDE_EDIT_FORM'] = 'Y';
742 $componentParams['SHOW_RATING'] = 'N';
743 $componentParams['USE_TASKS'] = 'N';
744 $componentParams['SHOW_EVENT_ID_FILTER'] = 'N';
745 $componentParams['USE_FAVORITES'] = 'N';
746 $componentParams['SHOW_NAV_STRING'] = 'N';
747 $componentParams['SET_LOG_PAGE_CACHE'] = 'N';
748 $componentParams['EVENT_ID'] = 'blog_post';
749 }
750 elseif ($componentParams['MODE'] === 'PUB')
751 {
752 $componentParams['PUBLIC_MODE'] = 'Y';
753 }
754 }
755 else
756 {
757 $componentParams['MODE'] = 'STANDARD';
758 $componentParams['USE_TASKS'] = (ModuleManager::isModuleInstalled('tasks') ? 'Y' : 'N');
759 }
760 }
761
762 public function prepareAvatarParams(&$componentParams): void
763 {
764 Util::checkEmptyParamInteger($componentParams, 'AVATAR_SIZE_COMMON', 100);
765 Util::checkEmptyParamInteger($componentParams, 'AVATAR_SIZE', 100);
766 Util::checkEmptyParamInteger($componentParams, 'AVATAR_SIZE_COMMENT', 100);
767 }
768
769 public function prepareNameTemplateParams(&$componentParams): void
770 {
771 Util::checkEmptyParamString($componentParams, 'NAME_TEMPLATE', \CSite::getNameFormat());
772
773 $componentParams['NAME_TEMPLATE_WO_NOBR'] = str_replace(
774 [ '#NOBR#', '#/NOBR#' ],
775 '',
776 $componentParams['NAME_TEMPLATE']
777 );
778 $componentParams['NAME_TEMPLATE'] = $componentParams['NAME_TEMPLATE_WO_NOBR'];
779 }
780
781 private function isSpace(array $componentParams): bool
782 {
783 return ($componentParams['CONTEXT'] ?? '') === Context::SPACES;
784 }
785
786 private function isSmartTrackingMode(array $componentParams): bool
787 {
788 if (!$this->isSpace($componentParams))
789 {
790 return true;
791 }
792
793 $switcher = SmartTracking::get(
794 $componentParams['SPACE_USER_ID'] ?? $componentParams['USER_ID'] ?? 0,
795 0,
797 );
798
799 return $switcher->isEnabled();
800 }
801}
prepareDateTimeFormatParams(&$componentParams)
Definition param.php:298
prepareCommentPropertyParams(&$componentParams)
Definition param.php:286
static checkEmptyParamString(&$params, $paramName, $defaultValue)
Definition util.php:15
static checkEmptyParamInteger(&$params, $paramName, $defaultValue)
Definition util.php:10