- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/bitrix24disk/legacy/diskstorage.php
- Класс: BitrixDiskBitrix24DiskLegacyDiskStorage
- Вызов: DiskStorage::moveDirectory
public function moveDirectory($name, $targetDirectoryId, $newParentDirectoryId)
{
if(!$newParentDirectoryId)
{
$newParentFolder = $this->storage->getRootObject();
}
else
{
$newParentFolder = Folder::loadById($newParentDirectoryId);
}
/** @var Folder $sourceFolder */
$sourceFolder = Folder::loadById($targetDirectoryId);
if(!$sourceFolder || !$newParentFolder)
{
$this->errorCollection->add(array(new Error("Could not " . __METHOD__ . " by id {$targetDirectoryId}", 11148)));
return false;
}
if(!$sourceFolder->canMove($this->storage->getSecurityContext($this->userId), $newParentFolder))
{
throw new AccessDeniedException;
}
$movedFolder = $sourceFolder->moveTo($newParentFolder, $this->getUser()->getId());
if($movedFolder)
{
$this->flushTreeCache();
$this->loadTree();
return $this->getDirectory(null, array('id' => $movedFolder->getId()), true);
}
$this->errorCollection->add(array(new Error("Could not " . __METHOD__ . ", moveTo to {$targetDirectoryId}", 11149)));
$this->errorCollection->add($sourceFolder->getErrors());
return array();
}