mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 03:22:29 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@741 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
6848735a30
commit
e71e466612
6 changed files with 66 additions and 3 deletions
|
|
@ -132,6 +132,49 @@
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 글의 첨부파일을 다른 글로 이동
|
||||
**/
|
||||
function moveFile($source_srl, $target_module_srl, $target_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$oFileModel = &getModel('file');
|
||||
$file_list = $oFileModel->getFiles($source_srl);
|
||||
if(!$file_list) return;
|
||||
|
||||
$file_count = count($file_list);
|
||||
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
|
||||
unset($file_info);
|
||||
$file_info = $file_list[$i];
|
||||
$old_file = $file_info->uploaded_filename;
|
||||
|
||||
// 이미지인지 기타 파일인지 체크하여 이동할 위치 정함
|
||||
if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info->source_filename)) {
|
||||
$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
|
||||
$new_file = $path.$file_info->source_filename;
|
||||
} else {
|
||||
$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
|
||||
$new_file = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
|
||||
}
|
||||
|
||||
// 디렉토리 생성
|
||||
FileHandler::makeDir($path);
|
||||
|
||||
// 파일 이동
|
||||
@rename($old_file, $new_file);
|
||||
|
||||
// DB 정보도 수정
|
||||
unset($args);
|
||||
$args->file_srl = $file_info->file_srl;
|
||||
$args->uploaded_filename = $new_file;
|
||||
$args->module_srl = $file_info->module_srl;
|
||||
$args->upload_target_srl = $target_srl;
|
||||
$oDB->executeQuery('file.updateFile', $args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief upload_target_srl을 키로 하는 첨부파일을 찾아서 java script 코드로 return
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
$args->upload_target_srl = $upload_target_srl;
|
||||
$args->sort_index = 'file_srl';
|
||||
$output = $oDB->executeQuery('file.getFiles', $args);
|
||||
if(!$output->data) return;
|
||||
|
||||
$file_list = $output->data;
|
||||
|
||||
|
|
|
|||
15
modules/file/queries/updateFile.xml
Normal file
15
modules/file/queries/updateFile.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<query id="updateFile" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="upload_target_srl" var="upload_target_srl" filter="number" default="0" notnull="notnull" />
|
||||
<column name="module_srl" var="module_srl" filter="number" default="0" notnull="notnull" />
|
||||
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||
<column name="regdate" var="regdate" default="curdate()" />
|
||||
<column name="ipaddress" var="ipaddress" default="ipaddress()" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue