• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/diskdispatcher.php
  • Класс: CWebDavDiskDispatcher
  • Вызов: CWebDavDiskDispatcher::processActionDelete
public function processActionDelete(array $params)
{
	$this->enableIgnoreQuotaError();
	$this->checkRequiredParams($params, array('id', 'version', 'extra', 'storageExtra', 'storageId')); //isDirectory

	$id = $params['id'];
	$version = $params['version'];
	$isDirectory = (bool)$params['isDirectory'];

	$lastVersion = null;
	$isDirectory = (bool)$isDirectory;
	$storage = $this->getStorageObject($params['storageExtra'], $params['storageId']);
	$extra = $storage->parseElementExtra($params['extra']);

	$element = $isDirectory?
		$storage->getDirectory($id, $extra):
		$storage->getFile($id, $extra);

	//todo check invite, if file under symlink
	if($element && $extra['inSymlink'])
	{
		$chain = CWebDavSymlinkHelper::getNavChain($element['extra']['iblockId'], $element['extra']['sectionId']);
		$sectionIds = array();
		foreach ($chain as $item)
		{
			$sectionIds[] = $item['ID'];
		}
		unset($item, $chain);

		//has current user invite on this section?
		$query = BitrixWebdavFolderInviteTable::getList(array(
			'select' => array('ID'),
			'filter' => array(
				'INVITE_USER_ID' => $this->getUser()->getId(),
				'IS_APPROVED' => true,
				'IS_DELETED' => false,
				'SECTION_ID' => $sectionIds,
			),
		));
		$row = $query->fetch();
		if(!isset($row['ID']))
		{
			return $this->sendResponse(array(
				'status' => static::STATUS_NOT_FOUND,
				'message'=> 'Link detached'
			));
		}
	}

	if($element)
	{
		if($storage::compareVersion($element['version'], $version) > 0)
		{
			$element['status'] = static::STATUS_OLD_VERSION;
			return $this->sendResponse($element);
		}
		$lastVersion = $isDirectory?
			$storage->deleteDirectory($element):
			$storage->deleteFile($element);
	}
	else //is already removed?
	{
		$lastVersion = $storage->getVersionDelete(array(
			'id' => $id,
			'version' => $version,
			'isDirectory' => $isDirectory,
			'extra' => $extra,
		));
	}

	if((bool)$lastVersion)
	{
		CWebDavTools::runEvent(($isDirectory? static::ON_AFTER_DISK_FOLDER_DELETE : static::ON_AFTER_DISK_FILE_DELETE), array($element['extra']['id'], $element));
		return $this->sendSuccess(array('version' => $this->convertToExternalVersion((string)$lastVersion)));
	}
	return $this->sendResponse(array('status' => static::STATUS_NOT_FOUND));
}