- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/checklist/internals/checklist.php
- Класс: BitrixTasksCheckListInternalsCheckList
- Вызов: CheckList::processUpdate
private function processUpdate()
{
/** @noinspection PhpVariableNamingConventionInspection */
global $USER_FIELD_MANAGER;
$updateResult = new Result();
$id = $this->fields->getId();
$facade = $this->facade;
/** @noinspection PhpUndefinedVariableInspection */
$oldItemFields = (($facade::$oldItemsToMerge[$id] ?? null) ?: $facade::getList([], ['ID' => $id])[$id]);
$oldItem = new CheckList(0, $this->userId, $facade, $oldItemFields);
$changedFields = $this->getChangedFields($oldItem->getFields());
$tableFields = $changedFields['TABLE'];
$commonFields = $changedFields['COMMON'];
if (array_key_exists('SORT_INDEX', $tableFields) || array_key_exists('PARENT_ID', $commonFields))
{
$this->recountSortIndexes(Application::getConnection());
}
if (!empty($tableFields))
{
$checkListDataController = $this->checkListDataController;
$updateTableResult = $checkListDataController::update($id, $tableFields);
if (!$updateTableResult->isSuccess())
{
$facade::logError($updateTableResult->getErrorMessages()[0]);
}
}
if (array_key_exists('MEMBERS', $commonFields))
{
try
{
$this->updateMembers($oldItem->fields->getMembers(), $this->fields->getMembers());
}
catch (Exception $exception)
{
$facade::logError($exception->getMessage());
}
}
if (array_key_exists('ATTACHMENTS', $commonFields) && ModuleManager::isModuleInstalled('disk'))
{
$userFields = ['UF_CHECKLIST_FILES' => $commonFields['ATTACHMENTS']];
$USER_FIELD_MANAGER->Update($this->userFieldsEntityIdName, $id, $userFields, $this->userId);
$this->setFields(['ATTACHMENTS' => $facade::getList(['ATTACHMENTS'], ['ID' => $id])[$id]['ATTACHMENTS']]);
}
$newParentId = ($commonFields['PARENT_ID'] ?? null);
if (isset($newParentId))
{
$checkListTree = $this->checkListTree;
if ($newParentId === 0)
{
$detachResult = $checkListTree::detachSubTree($id);
if (!$detachResult->isSuccess())
{
$updateResult->loadErrors($detachResult->getErrors());
return $updateResult;
}
}
else
{
$attachResult = $checkListTree::attach($id, $newParentId);
if (!$attachResult->isSuccess())
{
$updateResult->loadErrors($attachResult->getErrors());
return $updateResult;
}
}
}
$facade::doUpdatePostActions($this->fields->getEntityId(), $this->userId, $oldItem, $this);
return $updateResult;
}