protected function getDeletedElements($version) { $deletedItems = array(); $version = CWebDavDiskDispatcher::convertFromExternalVersion($version); if (!$version) { return array(); } $storageId = $this->getStorageId(); $query = CWebDavLogDeletedElement::getList(array(), array('VERSION' => $version, 'IBLOCK_ID' => $storageId['IBLOCK_ID'], 'SECTION_ID' => $storageId['IBLOCK_SECTION_ID'])); if (!$query) { throw new Exception('Error in DB'); } while ($row = $query->fetch()) { if (!$row) { continue; } $deletedItems[] = array('id' => $row['ELEMENT_ID'], 'isDirectory' => (bool) $row['IS_DIR'], 'deletedBy' => (string) (isset($row['USER_ID']) ? $row['USER_ID'] : 0), 'isDeleted' => true, 'storageId' => $this->getStringStorageId(), 'version' => CWebDavDiskDispatcher::convertToExternalVersion($row['VERSION'])); } return $deletedItems; }
public static function markDeleteBatch($deleteInviteOnSection = true) { if (empty(static::$dataDeletingMark)) { return false; } /** @var CWebDavDiskDispatcher $component */ $component = new static(); /** @var CWebDavAbstractStorage $storage */ $storage = $component->getStorageObject(); global $USER; $userId = $USER->getId(); $keeper = array(); $sectionIds = array(); foreach (static::$dataDeletingMark as $key => $data) { list($userIds, $sectionOwnersElement) = $data['ownerData']; foreach ($sectionOwnersElement as $ownerSection) { if (empty($ownerSection['IBLOCK_ID']) || empty($ownerSection['SECTION_ID'])) { continue; } $storage->setStorageId(array('IBLOCK_ID' => $ownerSection['IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $ownerSection['SECTION_ID'])); $uniqueId = $storage->generateId(array('FILE' => !$data['isSection'], 'ID' => $data['ID'])); $keeper[] = array('IBLOCK_ID' => $ownerSection['IBLOCK_ID'], 'SECTION_ID' => $ownerSection['SECTION_ID'], 'ELEMENT_ID' => $uniqueId, 'USER_ID' => $userId, 'IS_DIR' => (int) $data['isSection']); if ($data['isSection'] && !isset($sectionIds[$data['ID']])) { $sectionIds[$data['ID']] = $data['ID']; } } unset($ownerSection); unset(static::$dataDeletingMark[$key]); } unset($data); if ($deleteInviteOnSection && $sectionIds) { \Bitrix\Webdav\FolderInviteTable::deleteByFilter(array('=SECTION_ID' => $sectionIds)); } CWebDavLogDeletedElement::addBatch($keeper); }