mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Fix #975 do not move file when moving document
문서를 다른 게시판으로 이동할 때 첨부파일 경로를 변경하지 않도록 하여 아래와 같은 문제 발생을 사전에 차단합니다. - 본문에 삽입한 이미지 경로와 실제 파일이 저장된 경로가 달라지는 문제 - 경로 변경에 실패하여 파일이 증발하는 문제 단, files/attach/(images|binaries)/(기존 게시판의 module_srl) 폴더에 파일이 그대로 남아 있게 되므로, 게시판 삭제 후 해당 폴더를 수동으로 삭제하면 문제가 될 수 있습니다. 더이상 게시판의 module_srl과 해당 폴더에 저장된 파일들의 소속 모듈이 일치하지 않을 수 있다는 뜻입니다.
This commit is contained in:
parent
09f22aa42e
commit
c431855bbf
2 changed files with 23 additions and 34 deletions
|
|
@ -93,47 +93,22 @@ class documentAdminController extends document
|
|||
// Move the attached file if the target module is different
|
||||
if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
|
||||
{
|
||||
$oFileController = getController('file');
|
||||
|
||||
$files = $oDocument->getUploadedFiles();
|
||||
$delete_file_srls = array();
|
||||
if(is_array($files))
|
||||
$args = new stdClass;
|
||||
$args->module_srl = $module_srl;
|
||||
$args->upload_target_srl = $oDocument->get('document_srl');
|
||||
$output = executeQuery('file.updateFileModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
foreach($files as $val)
|
||||
{
|
||||
$file_info = array();
|
||||
$file_info['tmp_name'] = $val->uploaded_filename;
|
||||
$file_info['name'] = $val->source_filename;
|
||||
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true);
|
||||
if($inserted_file && $inserted_file->toBool())
|
||||
{
|
||||
// for image/video files
|
||||
if($val->direct_download == 'Y')
|
||||
{
|
||||
$source_filename = substr($val->uploaded_filename,2);
|
||||
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
|
||||
$obj->content = str_replace($source_filename, $target_filename, $obj->content);
|
||||
// For binary files
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
|
||||
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
|
||||
}
|
||||
}
|
||||
$delete_file_srls[] = $val->file_srl;
|
||||
}
|
||||
// Delete an existing file
|
||||
$oFileController->deleteFile($delete_file_srls);
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
// Set the all files to be valid
|
||||
$oFileController->setFilesValid($obj->document_srl);
|
||||
}
|
||||
|
||||
if($module_srl != $obj->module_srl)
|
||||
{
|
||||
$oDocumentController->deleteDocumentAliasByDocument($obj->document_srl);
|
||||
}
|
||||
|
||||
// Move a module of the article
|
||||
$obj->module_srl = $module_srl;
|
||||
$obj->category_srl = $category_srl;
|
||||
|
|
@ -152,12 +127,14 @@ class documentAdminController extends document
|
|||
return $update_output;
|
||||
}
|
||||
}
|
||||
//Move a module of the extra vars
|
||||
|
||||
// Move a module of the extra vars
|
||||
$output = executeQuery('document.moveDocumentExtraVars', $obj);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Set 0 if a new category doesn't exist after catergory change
|
||||
if($source_category_srl != $category_srl)
|
||||
{
|
||||
|
|
@ -169,6 +146,7 @@ class documentAdminController extends document
|
|||
$args = new stdClass();
|
||||
$args->document_srls = implode(',',$document_srl_list);
|
||||
$args->module_srl = $module_srl;
|
||||
|
||||
// move the comment
|
||||
$output = executeQuery('comment.updateCommentModule', $args);
|
||||
if(!$output->toBool())
|
||||
|
|
|
|||
11
modules/file/queries/updateFileModule.xml
Normal file
11
modules/file/queries/updateFileModule.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="updateFileModule" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue