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

	if (!$task->isAllowedTimeTracking())
	{
		$this->controller->addError(static::class, 'Time tracking is not allowed');
		return false;
	}

	if (
		$task->isClosed()
		|| $task->getStatus() === Status::SUPPOSEDLY_COMPLETED
	)
	{
		$this->controller->addError(static::class, 'Task already completed');
		return false;
	}

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

	if (
		$task->isMember($this->user->getUserId(), RoleDictionary::ROLE_RESPONSIBLE)
		|| $task->isMember($this->user->getUserId(), RoleDictionary::ROLE_ACCOMPLICE)
	)
	{
		return true;
	}

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

	if ($this->isSubordinateTask($task))
	{
		return true;
	}

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