...Человеческий поиск в разработке...
- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/replica/taskchecklistitemhandler.php
- Класс: BitrixTasksReplicaTaskChecklistItemHandler
- Вызов: TaskChecklistItemHandler::onExecuteCheckListItemMoveItem
function onExecuteCheckListItemMoveItem(BitrixMainEvent $event) { $parameters = $event->getParameters(); $selectedItemId = (int)$parameters[0]; $insertAfterItemId = (int)$parameters[1]; if ($selectedItemId > 0 && $insertAfterItemId > 0) { $connection = Application::getConnection(); $items = $this->getItems($selectedItemId, $connection); $newSortIndex = (int)$items[$insertAfterItemId]['SORT_INDEX'] + 1; $oldSortIndex = (int)$items[$selectedItemId]['SORT_INDEX']; $newParentId = (int)$items[$insertAfterItemId]['PARENT_ID']; $oldParentId = (int)$items[$selectedItemId]['PARENT_ID']; $nextIndex = $newSortIndex + 1; $prevIndex = $oldSortIndex; $recountedSortIndexes = []; foreach ($items as $id => $item) { $parentId = (int)$item['PARENT_ID']; $sortIndex = (int)$item['SORT_INDEX']; if ($parentId === $newParentId && $sortIndex >= $newSortIndex) { $recountedSortIndexes[$id] = $nextIndex; $nextIndex++; } else if ($parentId === $oldParentId && $sortIndex > $oldSortIndex) { $recountedSortIndexes[$id] = $prevIndex; $prevIndex++; } } $recountedSortIndexes[$selectedItemId] = $newSortIndex; $this->updateSortIndexes($recountedSortIndexes, $connection); $this->updateParents($newParentId, $oldParentId, $selectedItemId); } }