public static function deleteSymLinkOnSectionByUserIds(array $userIds, array $sectionLinkData, $typeLibrary = self::ENTITY_TYPE_USER) { if (empty($sectionLinkData['ID']) || empty($sectionLinkData['IBLOCK_ID'])) { return false; } $typeLibrary = strtolower($typeLibrary); if ($typeLibrary != self::ENTITY_TYPE_USER && $typeLibrary != self::ENTITY_TYPE_GROUP && $typeLibrary != self::ENTITY_TYPE_SHARED) { return false; } return \Bitrix\Webdav\FolderInviteTable::deleteByFilter(array('=IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], '=SECTION_ID' => $sectionLinkData['ID'], 'INVITE_USER_ID' => $userIds)); }
function DELETE($options) { $options["~path"] = $this->_udecode($options["path"]); WDUnpackCookie(); if (isset($options['path'])) { $arPath = explode('/', $options['path']); // ms excel tries to create and delete ~\$FileName.xls $basename = array_pop($arPath); $basename = $this->CorrectName($this->_udecode($basename)); array_push($arPath, $basename); $options['path'] = implode('/', $arPath); } if (!empty($options["~path"]) && $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"]) { $this->IsDir($options); $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] = ""; WDPackCookie(); if (intVal($this->arParams["element_id"]) > 0) { $this->_ib_elm_delete($this->arParams["element_id"]); return "204 No Content"; } return "404 Not Found"; } else { $this->IsDir($options); //symlink logic list($contextType, $contextEntityId) = $this->getContextData(); //we can't forward delete symlink. Only delete symlink section. $sectionData = $this->getSectionDataForLinkAnalyze($this->arParams['is_dir'] ? $this->arParams['dir_array']['ID'] : $this->arParams['element_array']['IBLOCK_SECTION_ID'], array(), false); if (CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData)) { //we don't enable symlink mode, because we move to real trash $parentSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData); if ($parentSectionData) { $linkWebdav = new self($parentSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array('ROOT_SECTION_ID' => $parentSectionData[self::UF_LINK_ROOT_SECTION_ID])); return $linkWebdav->DELETE($options); } else { return "404 Not Found"; } } if (!$this->CheckWebRights("DELETE", array('action' => 'delete', 'arElement' => $this->arParams), false)) { return $this->ThrowAccessDenied(__LINE__); } $resLock = array(); $lockedBy = $lockedDate = null; $resLock["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($this->arParams["item_id"], $lockedBy, $lockedDate); if ($resLock['LOCK_STATUS'] == 'red' && !$GLOBALS['USER']->CanDoOperation('webdav_change_settings')) { return $this->ThrowAccessDenied(__LINE__); } //delete symlink. Not move to trash if (!empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID])) { $options['force'] = true; } if (!isset($options['force']) && ($this->arParams["is_dir"] === true || intval($this->arParams["element_id"]) > 0)) { if ($trashID = $this->GetMetaID("TRASH")) { $item_id = $this->arParams['item_id']; $arSectionsChain = array(); $bRootFounded = empty($this->arRootSection) ? true : false; foreach (CWebDavSymlinkHelper::getNavChain($this->IBLOCK_ID, $this->arParams['parent_id']) as $res) { if (!$bRootFounded && $res["ID"] == $this->arRootSection["ID"]) { $bRootFounded = true; continue; } if (!$bRootFounded) { continue; } $arSectionsChain[] = $res["ID"]; } if ($item_id == $trashID && $this->arParams["is_dir"]) { if ($this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false)) { if (isset($this->attributes['user_id']) && $this->attributes['user_id'] == $GLOBALS['USER']->GetID()) { //now we clean own bin so simple, so fast $this->runCleaningTrash($trashID); } else { //old cleaning. So-so $this->_delete_section($options["section_id"]); } $this->GetMetaID('TRASH'); // create return "204 No Content"; } else { return $this->ThrowAccessDenied(__LINE__); } } elseif (!in_array($trashID, $arSectionsChain) && strpos($this->arParams['file_name'], "_\$") !== 0) { return $this->_move_to_trash($options); } } else { return "404 Not Found"; } } $this->IsDir($options); if (!$this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false)) { return $this->ThrowAccessDenied(__LINE__); } if ($this->arParams["is_dir"] === true) { if ($this->check_creator) { return $this->ThrowAccessDenied(__LINE__); } if ($this->_delete_section($options["section_id"]) === true && !empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID]) && $this->attributes['user_id']) { if (!empty($this->attributes['user_id'])) { CWebDavDiskDispatcher::sendChangeStatus($this->attributes['user_id'], 'delete_symlink'); } \Bitrix\Webdav\FolderInviteTable::deleteByFilter(array('=INVITE_USER_ID' => $this->attributes['user_id'], '=IS_APPROVED' => true, '=IBLOCK_ID' => $this->arParams['dir_array'][self::UF_LINK_IBLOCK_ID], '=SECTION_ID' => $this->arParams['dir_array'][self::UF_LINK_SECTION_ID])); } } elseif (intVal($this->arParams["element_id"]) > 0) { CWebDavDiskDispatcher::addElementForDeletingMark($this->arParams['element_array'], null, false); $el = new CIBlockElement(); $this->_onEvent('Delete', $this->arParams["element_id"]); if ($this->_ib_elm_delete($this->arParams["element_id"])) { CWebDavDiskDispatcher::markDeleteBatch(); CWebDavDiskDispatcher::sendEventToOwners($this->arParams['element_array'], null, 'force_delete_element'); } else { CWebDavDiskDispatcher::clearDeleteBatch(); } } else { return "404 Not Found"; } if ($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == $options["~path"]) { $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] = ""; } } return "204 No Content"; }
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); }