From f14af52fb3d74c9d10f0e7a0adc0ba3176b692d9 Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 7 Jan 2008 13:19:43 +0000 Subject: [PATCH] =?UTF-8?q?#294=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99/=EB=B3=B5=EC=82=AC=EC=8B=9C=20=EC=B2=A8=EB=B6=80?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EA=B3=BC=20=EB=8C=93=EA=B8=80/=EC=97=AE?= =?UTF-8?q?=EC=9D=B8=EA=B8=80=EB=8F=84=20=EB=AA=A8=EB=91=90=20=EB=B3=B5?= =?UTF-8?q?=EC=82=AC=EB=90=98=EB=8F=84=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3490 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../document/document.admin.controller.php | 104 +++++++++++++++++- .../document/queries/updateDocumentModule.xml | 1 + modules/file/file.controller.php | 1 + modules/point/point.controller.php | 2 +- 4 files changed, 101 insertions(+), 7 deletions(-) diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index 5e0a5125d..d96b8446e 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -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(); diff --git a/modules/document/queries/updateDocumentModule.xml b/modules/document/queries/updateDocumentModule.xml index 8c8dafd50..f3dfa097f 100644 --- a/modules/document/queries/updateDocumentModule.xml +++ b/modules/document/queries/updateDocumentModule.xml @@ -5,6 +5,7 @@ + diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index cfc319502..f6936677f 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -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; } diff --git a/modules/point/point.controller.php b/modules/point/point.controller.php index 665376d2c..8b1100e66 100644 --- a/modules/point/point.controller.php +++ b/modules/point/point.controller.php @@ -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;