set the original file name will other adjust the file type

This commit is contained in:
Uwe Steinmann 2025-11-19 20:31:24 +01:00
parent 3bedbd48a8
commit 580fa92393

View File

@ -694,20 +694,28 @@ switch($command) {
$document = $content->getDocument();
if ($document->getAccessMode($user) >= M_READWRITE) {
$oldname = $content->getOriginalFileName();
if (!$content->setOriginalFilename($_REQUEST['name'])) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>'Error setting original file name', 'data'=>''));
} else {
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($document->getId())) {
$index->reindexDocument($hit->id);
$index->commit();
$newname = trim($_REQUEST['name']);
if ($oldname != $newname) {
if (!$content->setOriginalFilename($newname)) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>'Error setting original file name', 'data'=>''));
} else {
$fileType = pathinfo($newname, PATHINFO_EXTENSION);
$content->setFileType($fileType);
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($document->getId())) {
$index->reindexDocument($hit->id);
$index->commit();
}
}
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_changed'), 'data'=>''));
add_log_line("set original filename '".$_REQUEST['name']."' of document ".$document->getId().":".$content->getVersion());
}
} else {
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_changed'), 'data'=>''));
add_log_line("set original filename '".$_REQUEST['name']."' of document ".$document->getId().":".$content->getVersion());
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_unchanged'), 'data'=>''));
}
} else {
header('Content-Type: application/json');