mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
게시글/모듈 삭제시 첨부파일을 정확히 추적하여 삭제하도록 코드 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4377 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d98583921d
commit
b206a07524
4 changed files with 60 additions and 10 deletions
|
|
@ -157,6 +157,25 @@
|
||||||
@rmdir($path);
|
@rmdir($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 지정된 디렉토리에 내용이 없으면 삭제
|
||||||
|
**/
|
||||||
|
function removeBlankDir($path) {
|
||||||
|
$item_cnt = 0;
|
||||||
|
|
||||||
|
$path = FileHandler::getRealPath($path);
|
||||||
|
if(!is_dir($path)) return;
|
||||||
|
$directory = dir($path);
|
||||||
|
while($entry = $directory->read()) {
|
||||||
|
if ($entry == "." || $entry == "..") continue;
|
||||||
|
if (is_dir($path."/".$entry)) $item_cnt = FileHandler::removeBlankDir($path.'/'.$entry);
|
||||||
|
}
|
||||||
|
$directory->close();
|
||||||
|
|
||||||
|
if($item_cnt < 1) @rmdir($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @biref 지정된 디렉토리를 제외한 모든 파일을 삭제
|
* @biref 지정된 디렉토리를 제외한 모든 파일을 삭제
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,34 @@
|
||||||
* @brief 특정 모두의 첨부파일 모두 삭제
|
* @brief 특정 모두의 첨부파일 모두 삭제
|
||||||
**/
|
**/
|
||||||
function deleteModuleFiles($module_srl) {
|
function deleteModuleFiles($module_srl) {
|
||||||
|
// 전체 첨부파일 목록을 구함
|
||||||
|
$args->module_srl = $module_srl;
|
||||||
|
$output = executeQuery('file.getModuleFiles',$args);
|
||||||
|
if(!$output) return $output;
|
||||||
|
$files = $output->data;
|
||||||
|
|
||||||
|
// DB에서 삭제
|
||||||
$args->module_srl = $module_srl;
|
$args->module_srl = $module_srl;
|
||||||
$output = executeQuery('file.deleteModuleFiles', $args);
|
$output = executeQuery('file.deleteModuleFiles', $args);
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
// 실제 파일 삭제
|
// 실제 파일 삭제 (일단 약속에 따라서 한번에 삭제)
|
||||||
$path[0] = sprintf("./files/attach/images/%s/", $module_srl);
|
FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ;
|
||||||
$path[1] = sprintf("./files/attach/binaries/%s/", $module_srl);
|
FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) );
|
||||||
FileHandler::removeDir($path[0]);
|
|
||||||
FileHandler::removeDir($path[1]);
|
// DB에서 구한 파일 목록을 삭제
|
||||||
|
$path = array();
|
||||||
|
$cnt = count($files);
|
||||||
|
for($i=0;$i<$cnt;$i++) {
|
||||||
|
$uploaded_filename = $files[$i]->uploaded_filename;
|
||||||
|
FileHandler::removeFile($uploaded_filename);
|
||||||
|
|
||||||
|
$path_info = pathinfo($uploaded_filename);
|
||||||
|
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 해당 글의 첨부파일 디렉토리 삭제
|
||||||
|
for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -374,16 +374,20 @@
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
// 실제 파일 삭제
|
// 실제 파일 삭제
|
||||||
|
$path = array();
|
||||||
$file_count = count($file_list);
|
$file_count = count($file_list);
|
||||||
for($i=0;$i<count($file_count);$i++) {
|
for($i=0;$i<$file_count;$i++) {
|
||||||
|
$uploaded_filename = $file_list[$i]->uploaded_filename;
|
||||||
|
FileHandler::removeFile($uploaded_filename);
|
||||||
$module_srl = $file_list[$i]->module_srl;
|
$module_srl = $file_list[$i]->module_srl;
|
||||||
$path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $upload_target_srl);
|
|
||||||
$path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $upload_target_srl);
|
|
||||||
|
|
||||||
FileHandler::removeDir($path[0]);
|
$path_info = pathinfo($uploaded_filename);
|
||||||
FileHandler::removeDir($path[1]);
|
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 해당 글의 첨부파일 디렉토리 삭제
|
||||||
|
for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
8
modules/file/queries/getModuleFiles.xml
Normal file
8
modules/file/queries/getModuleFiles.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<query id="getModuleFiles" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="files" />
|
||||||
|
</tables>
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||||
|
</conditions>
|
||||||
|
</query>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue