TaskFieldHandler::prepareParents

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. TaskFieldHandler
  4. prepareParents
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/handler/taskfieldhandler.php
  • Класс: BitrixTasksControlHandlerTaskFieldHandler
  • Вызов: TaskFieldHandler::prepareParents
public function prepareParents(): self
{
	if (!array_key_exists('PARENT_ID', $this->fields))
	{
		return $this;
	}

	$parentId = (int)$this->fields['PARENT_ID'];
	if (!$parentId)
	{
		$this->fields['PARENT_ID'] = false;

		return $this;
	}
	$this->fields['PARENT_ID'] = $parentId;

	$parentTask = (TaskRegistry::getInstance())->getObject($parentId);
	if (
		!$parentTask
		|| $parentTask->isDeleted()
		|| !TaskAccessController::can($this->userId, ActionDictionary::ACTION_TASK_READ, $parentId)
	)
	{
		throw new TaskFieldValidateException(Loc::getMessage('TASKS_BAD_PARENT_ID'));
	}

	if (!$this->taskId)
	{
		return $this;
	}

	if (ProjectDependenceTable::checkLinkExists($this->taskId, $parentId, ['BIDIRECTIONAL' => true]))
	{
		throw new TaskFieldValidateException(Loc::getMessage('TASKS_IS_LINKED_SET_PARENT'));
	}

	$result = Dependence::canAttach($this->taskId, $parentId);
	if (!$result->isSuccess() && ($errors = $result->getErrors()))
	{
		$messages = $errors->getMessages();
		throw new TaskFieldValidateException(array_shift($messages));
	}

	return $this;
}

Добавить комментарий