- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/project/provider.php
- Класс: BitrixTasksInternalsProjectProvider
- Вызов: Provider::addQueryFilter
private function addQueryFilter(Query $query, array $filterValues): Query
{
if (!CSocNetUser::isCurrentUserModuleAdmin())
{
$query->addFilter(
null,
[
'LOGIC' => 'OR',
'=VISIBLE' => 'Y',
'<=CONTEXT_RELATION.ROLE' => UserToGroupTable::ROLE_USER,
]
);
}
$filterManager = new WorkgroupListFilterManager(
$query,
$this->runtimeFieldsManager,
[
'fieldsList' => $this->getFieldsList(),
'gridFilter' => $filterValues,
'currentUserId' => $this->userId,
'contextUserId' => $this->userId,
'mode' => $this->mode,
'hasAccessToTasksCounters' => TasksCounter::getAccessToTasksCounters([
'mode' => $this->mode,
'contextUserId' => $this->userId,
]),
]
);
$filter = $filterManager->getFilter();
$siteId = SITE_ID;
if (
Loader::includeModule('extranet')
&& !CExtranet::IsIntranetUser($siteId, $this->userId)
)
{
$filter['=SITE.SITE_ID'] = CExtranet::GetExtranetSiteID();
}
foreach ($filter as $fieldName => $value)
{
if (
$fieldName === '=MEMBER_ID'
&& (int)$value > 0
)
{
$query->registerRuntimeField(
new Reference(
'MEMBER',
UserToGroupTable::class,
BitrixMainORMQueryJoin::on('this.ID', 'ref.GROUP_ID'),
['join_type' => 'INNER']
)
);
$this->runtimeFieldsManager->add('MEMBER');
$query->addFilter('=MEMBER.USER_ID', (int)$value);
$query->addFilter('<=MEMBER.ROLE', UserToGroupTable::ROLE_USER);
unset($filter[$fieldName]);
continue;
}
if (
$fieldName === 'INCLUDED_COUNTER'
&& $this->runtimeFieldsManager->has('TASKS_COUNTER')
)
{
$query->where(
Query::filter()
->whereNotNull('CONTEXT_RELATION.ID')
->whereIn('CONTEXT_RELATION.ROLE', UserToGroupTable::getRolesMember())
);
$condition = Query::filter()->whereIn('TASKS_COUNTER.TYPE', $value);
if ($this->runtimeFieldsManager->has('EXCLUDED_COUNTER_EXISTS'))
{
$condition->whereNull('EXCLUDED_COUNTER_EXISTS');
}
$query->where($condition);
unset($filter[$fieldName]);
continue;
}
if (
$fieldName === '%=TAG'
&& (string)$value !== ''
)
{
$query->registerRuntimeField(
new Reference(
'TAG',
WorkgroupTagTable::class,
Join::on('this.ID', 'ref.GROUP_ID'),
['join_type' => 'INNER']
)
);
$this->runtimeFieldsManager->add('TAG');
$query->addFilter('%=TAG.NAME', (string)$value);
unset($filter[$fieldName]);
continue;
}
if (
$fieldName === '=SCRUM'
&& (string)$value !== ''
&& $this->runtimeFieldsManager->has('SCRUM')
)
{
$query->addFilter('=SCRUM', (string)$value);
unset($filter[$fieldName]);
continue;
}
if (!$this->checkQueryFieldName($fieldName))
{
continue;
}
$query->addFilter($fieldName, $value);
}
return $query;
}