mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-27 18:10:42 +00:00
set the original file name will other adjust the file type
This commit is contained in:
parent
3bedbd48a8
commit
580fa92393
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user