From bf19a8cf2ae1d5c23c9760e8d6c13c0115461d9f Mon Sep 17 00:00:00 2001 From: zero Date: Tue, 10 Apr 2007 03:38:27 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@1062 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .htaccess | 12 ++-- classes/file/FileHandler.class.php | 14 ++++ common/lang/ko.lang.php | 3 + modules/board/board.controller.php | 44 +++++++++--- modules/board/conf/module.xml | 3 +- modules/board/lang/ko.lang.php | 1 + modules/board/tpl/checked_list.html | 13 ++-- .../tpl/filter/delete_checked_document.xml | 7 -- ...cument.xml => manage_checked_document.xml} | 2 +- modules/board/tpl/js/board_admin.js | 9 +++ .../comment/queries/updateCommentModule.xml | 11 +++ modules/document/document.controller.php | 67 +++++++++++++++++++ .../document/queries/updateDocumentModule.xml | 11 +++ modules/tag/queries/updateTagModule.xml | 11 +++ .../queries/updateTrackbackModule.xml | 11 +++ 15 files changed, 187 insertions(+), 32 deletions(-) delete mode 100644 modules/board/tpl/filter/delete_checked_document.xml rename modules/board/tpl/filter/{move_checked_document.xml => manage_checked_document.xml} (54%) create mode 100644 modules/comment/queries/updateCommentModule.xml create mode 100644 modules/document/queries/updateDocumentModule.xml create mode 100644 modules/tag/queries/updateTagModule.xml create mode 100644 modules/trackback/queries/updateTrackbackModule.xml diff --git a/.htaccess b/.htaccess index 5ab5eb795..e6150d5b3 100644 --- a/.htaccess +++ b/.htaccess @@ -1,6 +1,6 @@ -#RewriteEngine On -#RewriteRule ^rss/([[:alnum:]]+)$ ./?mid=$1&act=dispBoardRss [L] -#RewriteRule ^trackback/([[:digit:]]+)$ ./?module=trackback&act=procTrackbackReceive&document_srl=$1 [L] -#RewriteRule ^admin ./?module=admin [L] -#RewriteRule ^([[:digit:]]+)$ ./?document_srl=$1 [L] -#RewriteRule ^([[:alnum:]]+)$ ./?mid=$1 [L] +RewriteEngine On +RewriteRule ^rss/([[:alnum:]]+)$ ./?mid=$1&act=dispBoardRss [L] +RewriteRule ^trackback/([[:digit:]]+)$ ./?module=trackback&act=procTrackbackReceive&document_srl=$1 [L] +RewriteRule ^admin ./?module=admin [L] +RewriteRule ^([[:digit:]]+)$ ./?document_srl=$1 [L] +RewriteRule ^([[:alnum:]]+)$ ./?mid=$1 [L] diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 02504104d..489f61b69 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -32,6 +32,20 @@ fclose($fp); } + /** + * @brief 특정 디렉토리를 이동 + **/ + function moveDir($source_dir, $target_dir) { + if(!is_dir($source_dir)) return; + + if(!is_dir($target_dir)) { + FileHandler::makeDir($target_dir); + @unlink($target_dir); + } + + @rename($source_dir, $target_dir); + } + /** * @brief $path내의 파일들을 return ('.', '..', '.로 시작하는' 파일들은 제외) **/ diff --git a/common/lang/ko.lang.php b/common/lang/ko.lang.php index 84bc6daec..11f5c1d46 100644 --- a/common/lang/ko.lang.php +++ b/common/lang/ko.lang.php @@ -160,6 +160,9 @@ $lang->success_moved = '이동되었습니다'; $lang->success_sended = '발송되었습니다'; + $lang->fail_to_delete = '삭제되었습니다'; + $lang->fail_to_move = '이동되었습니다'; + $lang->failed_voted = '추천하실 수 없습니다'; $lang->fail_to_delete_have_children = '답글이 있어서 삭제할 수 없습니다'; diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index a20d13395..a44fadbfc 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -234,17 +234,41 @@ } /** - * @brief 세션에 담긴 선택글의 이동 + * @brief 세션에 담긴 선택글의 이동/ 삭제 **/ - function procBoardAdminMoveCheckedDocument() { - $this->setMessage('success_moved'); - } - - /** - * @brief 세션에 담긴 선택글의 삭제 - **/ - function procBoardAdminDeleteCheckedDocument() { - $this->setMessage('success_deleted'); + function procBoardAdminManageCheckedDocument() { + $type = Context::get('type'); + $module_srl = Context::get('target_board'); + $flag_list = $_SESSION['document_management'][$this->module_srl]; + + $document_srl_list = array_keys($flag_list); + + $oDocumentController = &getController('document'); + $document_srl_count = count($document_srl_list); + + if($type == 'move') { + if(!$module_srl) return new Object(-1, 'fail_to_move'); + else { + $output = $oDocumentController->moveDocumentModule($document_srl_list, $module_srl, $this->module_srl); + if(!$output->toBool()) return new Object(-1, 'fail_to_move'); + $msg_code = 'success_moved'; + $_SESSION['document_management'][$this->module_srl] = null; + } + + } elseif($type =='delete') { + $oDB = &DB::getInstance(); + $oDB->begin(); + for($i=0;$i<$document_srl_count;$i++) { + $document_srl = $document_srl_list[$i]; + $output = $oDocumentController->deleteDocument($document_srl, true); + if(!$output->toBool()) return new Object(-1, 'fail_to_delete'); + } + $oDB->commit(); + $msg_code = 'success_deleted'; + $_SESSION['document_management'][$this->module_srl] = null; + } + + $this->setMessage($msg_code); } /** diff --git a/modules/board/conf/module.xml b/modules/board/conf/module.xml index 440c39a91..f9926b816 100644 --- a/modules/board/conf/module.xml +++ b/modules/board/conf/module.xml @@ -66,7 +66,6 @@ - - + diff --git a/modules/board/lang/ko.lang.php b/modules/board/lang/ko.lang.php index 904c07c88..1b6ceacae 100644 --- a/modules/board/lang/ko.lang.php +++ b/modules/board/lang/ko.lang.php @@ -49,4 +49,5 @@ $lang->msg_category_is_null = '등록된 분류가 없습니다'; $lang->msg_grant_is_null = '등록된 권한 대상이 없습니다'; $lang->msg_no_checked_document = '선택된 게시물이 없습니다'; + $lang->msg_move_failed = '이동 실패하였습니다'; ?> diff --git a/modules/board/tpl/checked_list.html b/modules/board/tpl/checked_list.html index 6825275dc..7e972c1e1 100644 --- a/modules/board/tpl/checked_list.html +++ b/modules/board/tpl/checked_list.html @@ -1,5 +1,4 @@ - - +
@@ -8,19 +7,21 @@ -
+ + +
{$lang->checked_count} : {count($document_list)}
- +
- - {$lang->cmd_move} + {$lang->cmd_move}
diff --git a/modules/board/tpl/filter/delete_checked_document.xml b/modules/board/tpl/filter/delete_checked_document.xml deleted file mode 100644 index 941ef6b03..000000000 --- a/modules/board/tpl/filter/delete_checked_document.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
- - - - - diff --git a/modules/board/tpl/filter/move_checked_document.xml b/modules/board/tpl/filter/manage_checked_document.xml similarity index 54% rename from modules/board/tpl/filter/move_checked_document.xml rename to modules/board/tpl/filter/manage_checked_document.xml index 6c23e7a31..f2bd9641c 100644 --- a/modules/board/tpl/filter/move_checked_document.xml +++ b/modules/board/tpl/filter/manage_checked_document.xml @@ -1,4 +1,4 @@ - + diff --git a/modules/board/tpl/js/board_admin.js b/modules/board/tpl/js/board_admin.js index a3ec1fa90..148562b46 100644 --- a/modules/board/tpl/js/board_admin.js +++ b/modules/board/tpl/js/board_admin.js @@ -100,8 +100,17 @@ function doChangeCategory(sel_obj, url) { else location.href=url+'&module_category_srl='+module_category_srl; } +/* 선택된 글의 삭제 또는 이동 */ +function doManageDocument(type, mid) { + var fo_obj = xGetElementById("fo_management"); + fo_obj.type.value = type; + + procFilter(fo_obj, manage_checked_document); +} + /* 선택된 글의 삭제 또는 이동 후 */ function completeManageDocument(ret_obj) { + if(opener) opener.location.href = opener.location.href; alert(ret_obj['message']); window.close(); } diff --git a/modules/comment/queries/updateCommentModule.xml b/modules/comment/queries/updateCommentModule.xml new file mode 100644 index 000000000..8c1aa7872 --- /dev/null +++ b/modules/comment/queries/updateCommentModule.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index f80d14c06..f5778195d 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -285,6 +285,73 @@ return $output; } + /** + * @brief 특정 게시물들의 소속 모듈 변경 (게시글 이동시에 사용) + **/ + function moveDocumentModule($document_srl_list, $module_srl, $source_module_srl) { + $args->document_srls = implode(',',$document_srl_list); + $args->module_srl = $module_srl; + + $oDB = &DB::getInstance(); + $oDB->begin(); + + // 게시물의 이동 + $output = executeQuery('document.updateDocumentModule', $args); + if(!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // 코멘트의 이동 + $output = executeQuery('comment.updateCommentModule', $args); + if(!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // 트랙백의 이동 + $output = executeQuery('trackback.updateTrackbackModule', $args); + if(!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // 엮인글 + $output = executeQuery('tag.updateTagModule', $args); + if(!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // 첨부파일의 이동 (다운로드나 본문 첨부의 문제로 인하여 첨부파일은 이동하지 않기로 결정. 차후에 다시 고민) + /* + $image_dir = sprintf('./files/attach/images/%s/%s/', $source_module_srl, $document_srl); + $binary_dir = sprintf('./files/attach/binaries/%s/%s/', $source_module_srl, $document_srl); + + $target_image_dir = sprintf('./files/attach/images/%s/%s/', $module_srl, $document_srl); + $target_binary_dir = sprintf('./files/attach/binaries/%s/%s/', $module_srl, $document_srl); + + if(is_dir($image_dir)) { + FileHandler::moveDir($image_dir, $target_image_dir); + if(!is_dir($target_image_dir)) { + $oDB->rollback(); + return new Object(-1,'fail'); + } + } + + if(is_dir($binary_dir)) { + FileHandler::moveDir($binary_dir, $target_binary_dir); + if(!is_dir($target_binary_dir)) { + $oDB->rollback(); + return new Object(-1,'fail'); + } + } + */ + + $oDB->commit(); + return new Object(); + } + /** * @brief 특정 모듈의 전체 문서 삭제 **/ diff --git a/modules/document/queries/updateDocumentModule.xml b/modules/document/queries/updateDocumentModule.xml new file mode 100644 index 000000000..5c8f08166 --- /dev/null +++ b/modules/document/queries/updateDocumentModule.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/tag/queries/updateTagModule.xml b/modules/tag/queries/updateTagModule.xml new file mode 100644 index 000000000..58c136020 --- /dev/null +++ b/modules/tag/queries/updateTagModule.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/trackback/queries/updateTrackbackModule.xml b/modules/trackback/queries/updateTrackbackModule.xml new file mode 100644 index 000000000..21885ef86 --- /dev/null +++ b/modules/trackback/queries/updateTrackbackModule.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + +