protected function processMainUIFilterData(&$result): void
{
$request = $this->getRequest();
$params = $this->getComponent()->arParams;
if (
(
(
defined('SITE_TEMPLATE_ID')
&& SITE_TEMPLATE_ID === 'bitrix24'
)
|| (
isset($params['siteTemplateId'])
&& in_array($params['siteTemplateId'], [ 'bitrix24', 'landing24' ])
)
)
&& (int)$params['LOG_ID'] <= 0
&& (
$request->get('useBXMainFilter') === 'Y'
|| (($params['useBXMainFilter'] ?? '') === 'Y')
)
)
{
$filtered = false;
$filterOption = new BitrixMainUIFilterOptions($result['FILTER_ID']);
$filterData = $filterOption->getFilter();
$result['FILTER_USED'] = (!empty($filterData) ? 'Y' : 'N');
$this->setFilterData($filterData);
if (
!empty($filterData['GROUP_ID'])
&& preg_match('/^SG(d+)$/', $filterData['GROUP_ID'], $matches)
)
{
$this->setFilterKey('LOG_RIGHTS', 'SG' . (int)$matches[1]);
}
if (
!empty($filterData['AUTHOR_ID'])
&& preg_match('/^U(d+)$/', $filterData['AUTHOR_ID'], $matches)
)
{
$this->setFilterKey('USER_ID', (int)$matches[1]);
}
if (
!empty($filterData['CREATED_BY_ID'])
&& preg_match('/^U(d+)$/', $filterData['CREATED_BY_ID'], $matches)
)
{
$filtered = true;
$this->setFilterKey('USER_ID', (int)$matches[1]);
}
if (!empty($filterData['TO']))
{
if (preg_match('/^U(d+)$/', $filterData['TO'], $matches))
{
$this->setFilterKey('LOG_RIGHTS', 'U' . (int)$matches[1]);
if (empty($this->getFilterKey('USER_ID')))
{
$this->setFilterKey('!USER_ID', (int)$matches[1]);
}
}
elseif (preg_match('/^SG(d+)$/', $filterData['TO'], $matches))
{
$this->setFilterKey('LOG_RIGHTS', 'SG' . (int)$matches[1]);
}
elseif (preg_match('/^DR(d+)$/', $filterData['TO'], $matches))
{
$this->setFilterKey('LOG_RIGHTS', 'DR' . (int)$matches[1]);
}
elseif ($filterData['TO'] === 'UA')
{
$this->setFilterKey('LOG_RIGHTS', 'G2');
}
$filtered = !empty($this->getFilterKey('LOG_RIGHTS'));
}
if (
!empty($filterData['EXACT_EVENT_ID'])
&& !is_array($filterData['EXACT_EVENT_ID'])
)
{
$filtered = true;
$this->setFilterKey('EVENT_ID', [ $filterData['EXACT_EVENT_ID'] ]);
}
if (
!empty($filterData['EVENT_ID'])
&& is_array($filterData['EVENT_ID'])
)
{
$filtered = true;
$this->setFilterKey('EVENT_ID', []);
$eventIdFilterValue = $this->getFilterKey('EVENT_ID');
foreach ($filterData['EVENT_ID'] as $filterEventId)
{
// if specific blog_post event (important, vote, grat)
if (in_array($filterEventId, [ 'blog_post_important', 'blog_post_grat', 'blog_post_vote' ]))
{
$eventIdFilterValue[] = $filterEventId;
}
else
{
$eventIdFilterValue = array_merge($eventIdFilterValue, CSocNetLogTools::findFullSetByEventID($filterEventId));
}
}
$this->setFilterKey('EVENT_ID', array_unique($eventIdFilterValue));
}
if (
!empty($filterData['FAVORITES_USER_ID'])
&& $filterData['FAVORITES_USER_ID'] === 'Y'
)
{
$filtered = true;
$this->setFilterKey('>FAVORITES_USER_ID', 0);
}
if (
is_numeric($filterData['TAG'] ?? null)
|| !empty(trim($filterData['TAG'] ?? ''))
)
{
$filtered = true;
$this->setFilterKey('=TAG', trim($filterData['TAG']));
}
$this->setFilterContent(trim($filterData['FIND'] ?? ''));
$findValue = (string)$this->getFilterContent();
if ($findValue !== '')
{
$filtered = true;
$this->setFilterKey('*CONTENT', LogIndex::prepareToken($findValue));
}
if (
!empty($filterData['EXTRANET'])
&& $filterData['EXTRANET'] === 'Y'
&& Loader::includeModule('extranet')
)
{
$filtered = true;
$this->setFilterKey('SITE_ID', CExtranet::getExtranetSiteID());
$this->setFilterKey('!EVENT_ID', [ 'lists_new_element', 'tasks', 'timeman_entry', 'report', 'crm_activity_add' ]);
}
if (!empty($filterData['DATE_CREATE_from']))
{
$filtered = true;
if (!empty($this->getFilterContent()))
{
$this->setFilterKey('>=CONTENT_DATE_CREATE', $filterData['DATE_CREATE_from']);
}
else
{
$this->setFilterKey('>=LOG_DATE', $filterData['DATE_CREATE_from']);
}
}
if (!empty($filterData['DATE_CREATE_to']))
{
$filtered = true;
$dateCreateToValue = convertTimeStamp($this->makeTimeStampFromDateTime($filterData['DATE_CREATE_to'], 'SHORT') + 86399, 'FULL');
if (!empty($this->getFilterContent()))
{
$this->setFilterKey('<=CONTENT_DATE_CREATE', $dateCreateToValue);
}
else
{
$this->setFilterKey('<=LOG_DATE', $dateCreateToValue);
}
}
if ($filtered)
{
// extraordinal case, we cannot set arParams earlier
$params['SET_LOG_COUNTER'] = 'N';
$params['SET_LOG_PAGE_CACHE'] = 'N';
$params['USE_FOLLOW'] = 'N';
$params['SHOW_UNREAD'] = 'N';
$this->getComponent()->arParams = $params;
$result['SHOW_UNREAD'] = 'N';
$result['IS_FILTERED'] = true;
$this->showPinnedPanel = false;
}
}
elseif (
(
defined('SITE_TEMPLATE_ID')
&& SITE_TEMPLATE_ID === 'bitrix24'
)
|| $params['MODE'] === 'LANDING'
)
{
$filterOption = new BitrixMainUIFilterOptions($result['FILTER_ID']);
$filterOption->reset();
}
if (
(
$params['TAG'] !== ''
|| $params['FIND'] !== ''
)
&& $this->getRequest()->get('apply_filter') === 'Y'
)
{
$this->getComponent()->arParams['useBXMainFilter'] = 'Y';
}
}