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

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

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

	$this->oldTask = $this->newTask = $task;

	if (is_object($params) && $params instanceof TaskModel)
	{
		$this->newTask = $params;
	}

	if (!$this->canDelegate())
	{
		$this->controller->addError(static::class, 'Access to delegate denied');
		return false;
	}

	if (!$this->canAssignTask($this->oldTask, RoleDictionary::ROLE_RESPONSIBLE, $this->newTask, [$this->user->getUserId()]))
	{
		$this->controller->addError(static::class, 'Access to assign responsible denied');
		return false;
	}

	return true;
}