• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/access/rule/taskreadrule.php
  • Класс: BitrixTasksAccessRuleTaskReadRule
  • Вызов: TaskReadRule::execute
public function execute(AccessibleItem $task = null, $params = null): bool
{
	if (!$task)
	{
		$this->controller->addError(static::class, 'Incorrect task');
		return false;
	}

	if ($this->user->isAdmin())
	{
		return true;
	}

	if ($task->isMember($this->user->getUserId()))
	{
		return true;
	}

	if (
		$task->getGroupId()
		&& Loader::includeModule("socialnetwork")
		&& BitrixSocialnetworkInternalsRegistryFeaturePermRegistry::getInstance()->get(
			$task->getGroupId(),
			'tasks',
			'view_all',
			$this->user->getUserId()
		)
	)
	{
		return true;
	}

	// can read subordinate's task
	if ($this->isSubordinateTask($task, false))
	{
		return true;
	}

	$isInDepartment = $task->isInDepartment($this->user->getUserId(), false, [RoleDictionary::ROLE_RESPONSIBLE, RoleDictionary::ROLE_DIRECTOR, RoleDictionary::ROLE_ACCOMPLICE]);

	if (
		$this->user->getPermission(PermissionDictionary::TASK_DEPARTMENT_VIEW)
		&& $isInDepartment
	)
	{
		return true;
	}

	if (
		$this->user->getPermission(PermissionDictionary::TASK_NON_DEPARTMENT_VIEW)
		&& !$isInDepartment
	)
	{
		return true;
	}

	$this->controller->addError(static::class, 'Access to read task denied');
	return false;
}