#294 게시글 이동/복사시 첨부파일과 댓글/엮인글도 모두 복사되도록 기능 추가

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3490 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-01-07 13:19:43 +00:00
parent 3f28a71e8d
commit f14af52fb3
4 changed files with 101 additions and 7 deletions

View file

@ -142,13 +142,44 @@
$source_category_srl = $oDocument->get('category_srl');
unset($document_args);
$document_args->module_srl = $module_srl;
$document_args->category_srl = $category_srl;
$document_args->document_srl = $document_srl;
unset($obj);
$obj = $oDocument->getObjectVars();
// 첨부파일 이동
if($oDocument->hasUploadedFiles()) {
$oFileController = &getController('file');
$files = $oDocument->getUploadedFiles();
foreach($files as $key => $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($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);
// binary 파일일 경우
} 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);
}
// 기존 파일 삭제
$oFileController->deleteFile($val->file_srl);
}
// 등록된 모든 파일을 유효로 변경
$oFileController->setFilesValid($obj->document_srl);
}
// 게시물의 모듈 이동
$output = executeQuery('document.updateDocumentModule', $document_args);
$obj->module_srl = $module_srl;
$obj->category_srl = $category_srl;
$output = executeQuery('document.updateDocumentModule', $obj);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
@ -159,6 +190,7 @@
if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
}
}
$args->document_srls = implode(',',$document_srl_list);
@ -198,6 +230,8 @@
$oDocumentModel = &getModel('document');
$oDocumentController = &getController('document');
$oFileModel = &getModel('file');
$oDB = &DB::getInstance();
$oDB->begin();
@ -223,7 +257,19 @@
$file_info['tmp_name'] = $val->uploaded_filename;
$file_info['name'] = $val->source_filename;
$oFileController = &getController('file');
$oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
// 이미지/동영상등일 경우
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);
// binary 파일일 경우
} 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);
}
}
}
@ -233,6 +279,52 @@
$oDB->rollback();
return $output;
}
// 댓글 이전
if($oDocument->getCommentCount()) {
$oCommentModel = &getModel('comment');
$comments = $oCommentModel->getCommentList($document_srl, true);
if(count($comments)) {
$oCommentController = &getController('comment');
$success_count = 0;
$p_comment_srl = array();
foreach($comments as $comment_obj) {
$comment_srl = getNextSequence();
$p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
$comment_obj->module_srl = $obj->module_srl;
$comment_obj->document_srl = $obj->document_srl;
$comment_obj->comment_srl = $comment_srl;
if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
$output = $oCommentController->insertComment($comment_obj, true);
if($output->toBool()) $success_count ++;
}
$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
}
}
// 엮인글 이전
if($oDocument->getTrackbackCount()) {
$oTrackbackModel = &getModel('trackback');
$trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
if(count($trackbacks)) {
$success_count = 0;
foreach($trackbacks as $trackback_obj) {
$trackback_obj->trackback_srl = getNextSequence();
$trackback_obj->module_srl = $obj->module_srl;
$trackback_obj->document_srl = $obj->document_srl;
$output = executeQuery('trackback.insertTrackback', $trackback_obj);
if($output->toBool()) $success_count++;
}
// 엮인글 수 업데이트
$oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
}
}
}
$oDB->commit();

View file

@ -5,6 +5,7 @@
<columns>
<column name="module_srl" var="module_srl" filter="number" default="0" />
<column name="category_srl" var="category_srl" filter="number" default="0" />
<column name="content" var="content" notnull="notnull" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" notnull="notnull" />

View file

@ -386,6 +386,7 @@
$output->add('direct_download', $args->direct_download);
$output->add('source_filename', $args->source_filename);
$output->add('upload_target_srl', $upload_target_srl);
$output->add('uploaded_filename', $args->uploaded_filename);
return $output;
}

View file

@ -221,7 +221,7 @@
* 유효파일을 삭제할 경우에만 포인트 삭제
**/
function triggerDeleteFile(&$obj) {
if($obj->isvalid != 'Y') return Object();
if($obj->isvalid != 'Y') return new Object();
$module_srl = $obj->module_srl;
$member_srl = $obj->member_srl;