Joywork/admin/ajax/deleteDocument.php

40 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if ($_SESSION['id'] && isset($_SESSION['superadmin'])) {
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/DocTarget.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Block.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Apartment.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/BlockProgressImageFacade.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/BlockPlusFacade.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/TargetFactory.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/DocumentManager.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/provider/DocProvider.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/provider/DbDocProvider.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/Dir.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/RootDir.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/File.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/DocCollection.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/ar/Document.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/exception/DocNotFoundException.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/exception/TargetNotFoundException.php';
$targetId = $_POST['target_id'];
$targetType = $_POST['target_type'];
$docId = $_POST['doc_id'];
$manager = new DocumentManager((new TargetFactory())->getTarget($targetId, $targetType));
$doc = Document::findById($targetId, $targetType, $docId);
$manager->delete($docId);
$dirObject = $manager->getDir($doc->parent);
$path = $manager->getParents($dirObject->getId());
$collection = $manager->getChildren($dirObject->getId());
include($_SERVER['DOCUMENT_ROOT'] . "/admin/documentsWidget.php");
}