• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/uf/controller.php
  • Класс: BitrixDiskUfController
  • Вызов: Controller::processActionMoveUploadedFile
protected function processActionMoveUploadedFile()
{
	$this->checkRequiredPostParams(array('attachedId', 'targetFolderId'));

	if($this->errorCollection->hasErrors())
	{
		$this->sendJsonErrorResponse();
	}
	[$type, $objectId] = FileUserType::detectType($this->request->getPost('attachedId'));
	if($type != FileUserType::TYPE_NEW_OBJECT || !$objectId)
	{
		$this->errorCollection->add(array(new Error('Could not move attached file')));
		$this->sendJsonErrorResponse();
	}

	$targetFolderId = (int)$this->request->getPost('targetFolderId');
	/** @var File $file */
	$file = File::loadById($objectId, array('STORAGE'));
	if(!$file)
	{
		$this->errorCollection->add(array(new Error('Could not find file')));
		$this->sendJsonErrorResponse();
	}
	if($file->getCreatedBy() != $this->getUser()->getId())
	{
		$this->errorCollection->add(array(new Error('Could not move alien file')));
		$this->sendJsonErrorResponse();
	}
	/** @var Folder $targetFolder */
	$targetFolder = Folder::loadById($targetFolderId, array('STORAGE'));
	if(!$targetFolder)
	{
		$this->errorCollection->add(array(new Error('Could not find target folder')));
		$this->sendJsonErrorResponse();
	}
	if(!$file->canMove($file->getStorage()->getCurrentUserSecurityContext(), $targetFolder))
	{
		$this->errorCollection->add(array(new Error('Bad permission. Could not move this file')));
		$this->sendJsonErrorResponse();
	}
	if(!$file->moveToAnotherFolder($targetFolder, $this->getUser()->getId(), true))
	{
		$this->errorCollection->add(array(new Error('Could not move the file')));
		$this->sendJsonErrorResponse();
	}

	$this->sendJsonSuccessResponse();
}