TaskFieldHandler::isParentChanged

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

	if (!array_key_exists('PARENT_ID', $this->fields))
	{
		return false;
	}
	$this->fields['PARENT_ID'] = (int) $this->fields['PARENT_ID'];
	$this->taskData['PARENT_ID'] = (int) $this->taskData['PARENT_ID'];

	if ($this->fields['PARENT_ID'] === $this->taskData['PARENT_ID'])
	{
		return false;
	}

	/**
	 * Occurs when user does not know anything about main task but is trying to change its sub task.
	 * This method returns true in that case, so we should not change parent.
	 */
	try
	{
		if (UtilUser::isSuper($this->userId))
		{
			return true;
		}

		if (!$this->fields['PARENT_ID'] && $this->taskData['PARENT_ID'])
		{
			try
			{
				$parentTask = new CTaskItem($this->taskData['PARENT_ID'], $this->userId);
				$parentTask->getData(false, ['select' => ['ID'], 'bSkipExtraData' => true]);
			}
				/** @noinspection PhpDeprecationInspection */
			catch (TasksException | CTaskAssertException $e)
			{
				/** @noinspection PhpDeprecationInspection */
				if ($e->getCode() == TasksException::TE_TASK_NOT_FOUND_OR_NOT_ACCESSIBLE)
				{
					return false;
				}
			}
		}

		return true;
	}
	catch (Exception $exception)
	{
		return true;
	}
}

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