Joywork/admin/ajax/updateFiles.php

82 lines
3.6 KiB
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
$targetId = $_POST['target_id'];
$targetType = $_POST['target_type'];
if (isset($_POST['dir_id'])) {
$dirId = $_POST['dir_id'];
} else {
$dirId = 0;
}
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';
$manager = new DocumentManager((new TargetFactory())->getTarget($targetId, $targetType));
$dirObject = $manager->getDir($dirId);
$path = $manager->getParents($dirObject->getId());
$collection = $manager->getChildren($dirObject->getId());
include($_SERVER['DOCUMENT_ROOT'] . "/admin/documentsWidget.php");
}
if ($targetType == DocTarget::TYPE_BLOCK) {
?>
<script type="text/javascript">
$('#createFolderButton').attr('data-targetid', <?php echo $targetId; ?>);
$('#createFolderButton').attr('data-targettype', <?php echo $targetType; ?>);
$('#createFolderButton').attr('data-id', <?php echo $dirId; ?>);
$('#load_doc_target_id').val(<?php echo $targetId; ?>);
$('#load_doc_target_type').val(<?php echo $targetType; ?>);
$('#load_doc_fold_id').val(<?php echo $dirId; ?>);
</script>
<?php
}
if ($targetType == DocTarget::TYPE_BLOCK_PROGRESS) {
?>
<script type="text/javascript">
$('#createProgressFolderButton').attr('data-targetid', <?php echo $targetId; ?>);
$('#createProgressFolderButton').attr('data-targettype', <?php echo $targetType; ?>);
$('#createProgressFolderButton').attr('data-id', <?php echo $dirId; ?>);
$('#load_progress_target_id').val(<?php echo $targetId; ?>);
$('#load_progress_fold_id').val(<?php echo $dirId; ?>);
$('#load_progress_target_type').val(<?php echo $targetType; ?>);
</script>
<?php } ?>
<?php
if ($targetType == DocTarget::TYPE_BLOCK_PLUS) {
?>
<script type="text/javascript">
$('#createPlusFolderButton').attr('data-targetid', <?php echo $targetId; ?>);
$('#createPlusFolderButton').attr('data-targettype', <?php echo $targetType; ?>);
$('#createPlusFolderButton').attr('data-id', <?php echo $dirId; ?>);
$('#load_plus_target_id').val(<?php echo $targetId; ?>);
$('#load_plus_fold_id').val(<?php echo $dirId; ?>);
$('#load_plus_target_type').val(<?php echo $targetType; ?>);
</script>
<?php } ?>