• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/provider/taskprovider.php
  • Класс: BitrixTasksProviderTaskProvider
  • Вызов: TaskProvider::makeAccessSql
private function makeAccessSql(): self
{
	if (!$this->useAccessAsWhere)
	{
		return $this;
	}

	if ($this->userId !== $this->executorId)
	{
		$this->buildAccessSql();
		return $this;
	}

	if (CTasks::needAccessRestriction($this->arOptimizedFilter, $this->arParams))
	{
		$buildAccessSql = true;
		$this->arParams['APPLY_FILTER'] = CTasks::makePossibleForwardedFilter($this->arOptimizedFilter);

		if ($this->arParams['MAKE_ACCESS_FILTER'] ?? null)
		{
			$viewedUserId = CTasks::getViewedUserId($this->arFilter, $this->userId);

			$runtimeOptions = CTasks::makeAccessFilterRuntimeOptions($this->arFilter, [
				'USER_ID' => $this->userId,
				'VIEWED_USER_ID' => $viewedUserId
			]);

			if (!is_array($this->arParams['ACCESS_FILTER_RUNTIME_OPTIONS'] ?? null))
			{
				$this->arParams['ACCESS_FILTER_RUNTIME_OPTIONS'] = $runtimeOptions;
			}
			else
			{
				foreach ($runtimeOptions as $key => $value)
				{
					$this->arParams['ACCESS_FILTER_RUNTIME_OPTIONS'][$key] += $value;
				}
			}

			if ($viewedUserId == $this->userId)
			{
				$buildAccessSql = CTasks::checkAccessSqlBuilding($runtimeOptions);
			}
		}

		if ($buildAccessSql)
		{
			$this->buildAccessSql();
		}
	}

	return $this;
}