From 19a6b5fcc1e05d2b2414c096a20bdec8cb180ff5 Mon Sep 17 00:00:00 2001 From: rubyeye Date: Thu, 19 Mar 2009 04:27:16 +0000 Subject: [PATCH] =?UTF-8?q?=ED=9C=B4=EC=A7=80=ED=86=B5=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=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@5914 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/document/conf/module.xml | 2 + .../document/document.admin.controller.php | 38 ++++++++++ modules/document/document.admin.model.php | 69 ++++++++++++++++++ modules/document/document.admin.view.php | 27 +++++++ modules/document/document.controller.php | 65 +++++++++++++++++ modules/document/document.model.php | 1 - modules/document/lang/ko.lang.php | 25 +++++++ modules/document/queries/deleteTrash.xml | 8 ++ modules/document/queries/getTrash.xml | 11 +++ modules/document/queries/getTrashList.xml | 29 ++++++++ modules/document/queries/insertTrash.xml | 17 +++++ .../document/queries/updateCategoryCount.xml | 2 +- modules/document/schemas/document_trash.xml | 12 +++ modules/document/tpl/checked_list.html | 1 + modules/document/tpl/document_list.html | 10 ++- modules/document/tpl/document_trash_list.html | 73 +++++++++++++++++++ modules/document/tpl/header.html | 1 + modules/document/tpl/js/document_admin.js | 15 +++- 18 files changed, 400 insertions(+), 6 deletions(-) create mode 100644 modules/document/queries/deleteTrash.xml create mode 100644 modules/document/queries/getTrash.xml create mode 100644 modules/document/queries/getTrashList.xml create mode 100644 modules/document/queries/insertTrash.xml create mode 100644 modules/document/schemas/document_trash.xml create mode 100644 modules/document/tpl/document_trash_list.html diff --git a/modules/document/conf/module.xml b/modules/document/conf/module.xml index 60efeb36c..e3193eae3 100644 --- a/modules/document/conf/module.xml +++ b/modules/document/conf/module.xml @@ -26,6 +26,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index 28dc097bf..e433ca381 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -620,6 +620,44 @@ $alias_srl = Context::get('alias_srl'); $args->alias_srl = $alias_srl; $output = executeQuery("document.deleteAlias", $args); + if (!$output->toBool()) + { + return $output; + } + } + + function procDocumentAdminRestoreTrash() { + $trash_srl = Context::get('trash_srl'); + + $oDB = &DB::getInstance(); + + $trash_args->trash_srl = $trash_srl; + + $output = executeQuery('document.getTrash', $args); + if (!$output->toBool()) { + return $output; + } + + $document_args->document_srl = $output->data->document_srl; + $document_args->module_srl = $output->data->module_srl; + + // begin transaction + $oDB->begin(); + + $output = executeQuery('document.updateDocument', $document_args); + if (!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + $output = executeQuery('document.deleteTrash', $trash_args); + if (!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // commit + $oDB->commit(); } } diff --git a/modules/document/document.admin.model.php b/modules/document/document.admin.model.php index f0bccc047..3bb3e9e84 100644 --- a/modules/document/document.admin.model.php +++ b/modules/document/document.admin.model.php @@ -75,5 +75,74 @@ $this->add('tpl', $tpl); } + /** + * @brief 휴지통에 존재하는 문서 목록을 가져옴 + **/ + function getDocumentTrashList($obj) { + // 정렬 대상과 순서 체크 + if (!in_array($obj->sort_index, array('list_order','delete_date','title'))) $obj->sort_index = 'list_order'; + if (!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc'; + + // module_srl 대신 mid가 넘어왔을 경우는 직접 module_srl을 구해줌 + if ($obj->mid) { + $oModuleModel = &getModel('module'); + $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); + unset($obj->mid); + } + + // 넘어온 module_srl은 array일 수도 있기에 array인지를 체크 + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); + else $args->module_srl = $obj->module_srl; + + // 변수 체크 + $args->sort_index = $obj->sort_index; + $args->order_type = $obj->order_type; + $args->page = $obj->page?$obj->page:1; + $args->list_count = $obj->list_count?$obj->list_count:20; + $args->page_count = $obj->page_count?$obj->page_count:10; + $args->member_srl = $obj->member_srl; + + // query_id 지정 + $query_id = 'document.getTrashList'; + + // query 실행 + $output = executeQueryArray($query_id, $args); + + // 결과가 없거나 오류 발생시 그냥 return + if (!$output->toBool() || !count($output->data)) return $output; + + $idx = 0; + $data = $output->data; + unset($output->data); + + $keys = array_keys($data); + $virtual_number = $keys[0]; + + foreach($data as $key => $attribute) { + $oDocument = null; + $oDocument = new documentItem(); + $oDocument->setAttribute($attribute, false); + if ($is_admin) $oDocument->setGrant(); + + $output->data[$virtual_number] = $oDocument; + $virtual_number--; + } + + return $output; + } + + /** + * @brief trash_srl값을 가지는 휴지통 문서를 가져옴 + **/ + function getDocumentTrash($trash_srl) { + $args->trash_srl = $trash_srl; + $output = executeQuery('document.getTrash', $args); + + $node = $output->data; + if (!$node) return; + + return $node; + } + } ?> diff --git a/modules/document/document.admin.view.php b/modules/document/document.admin.view.php index 9bd7c8dbf..f9a2fbf28 100644 --- a/modules/document/document.admin.view.php +++ b/modules/document/document.admin.view.php @@ -128,5 +128,32 @@ $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('document_alias'); } + + function dispDocumentAdminTrashList() { + // 목록을 구하기 위한 옵션 + $args->page = Context::get('page'); ///< 페이지 + $args->list_count = 30; ///< 한페이지에 보여줄 글 수 + $args->page_count = 10; ///< 페이지 네비게이션에 나타날 페이지의 수 + + $args->sort_index = 'list_order'; ///< 소팅 값 + $args->order_type = 'desc'; ///< 소팅 정렬 값 + + $args->module_srl = Context::get('module_srl'); + + // 목록을 구함 + $oDocumentAdminModel = &getAdminModel('document'); + $output = $oDocumentAdminModel->getDocumentTrashList($args); + + // 템플릿에 쓰기 위해서 document_admin_model::getDocumentTrashList() 의 return object에 있는 값들을 세팅 + Context::set('total_count', $output->total_count); + Context::set('total_page', $output->total_page); + Context::set('page', $output->page); + Context::set('document_list', $output->data); + Context::set('page_navigation', $output->page_navigation); + + // 템플릿 지정 + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('document_trash_list'); + } } ?> diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 1087c8482..8f1258fe3 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -460,6 +460,59 @@ return $output; } + /** + * @brief 문서를 휴지통으로 옮김 + **/ + function moveDocumentToTrash($obj) { + // 주어진 trash_srl이 없으면 trash_srl 등록 + if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); + else $trash_args->trash_srl = $obj->trash_srl; + + // 해당 document가 속해 잇는 module_srl을 구한다 + $oDocumentModel = &getModel('document'); + $oDocument = $oDocumentModel->getDocument($obj->document_srl); + + $trash_args->module_srl = $oDocument->get('module_srl'); + + // 데이터 설정 + $trash_args->document_srl = $obj->document_srl; + $trash_args->description = $obj->description; + + // 수동 등록이 아니고 로그인 된 회원일 경우 회원의 정보를 입력 + if(Context::get('is_logged')&&!$manual_inserted) { + $logged_info = Context::get('logged_info'); + $trash_args->member_srl = $logged_info->member_srl; + $trash_args->user_id = $logged_info->user_id; + $trash_args->user_name = $logged_info->user_name; + $trash_args->nick_name = $logged_info->nick_name; + } + + // documents update를 위한 데이터 설정 + $document_args->module_srl = 0; + $document_args->document_srl = $obj->document_srl; + + // begin transaction + $oDB = &DB::getInstance(); + $oDB->begin(); + + $output = executeQuery('document.insertTrash', $trash_args); + if (!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + $output = executeQuery('document.updateDocument', $document_args); + if (!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // commit + $oDB->commit(); + + return $output; + } + /** * @brief 특정 모듈의 공지사항 글에 대해 캐시 **/ @@ -1326,6 +1379,18 @@ } $oDB->commit(); $msg_code = 'success_deleted'; + } elseif($type == 'trash') { + $args->description = $message_content; + + $oDB = &DB::getInstance(); + $oDB->begin(); + for($i=0;$i<$document_srl_count;$i++) { + $args->document_srl = $document_srl_list[$i]; + $output = $this->moveDocumentToTrash($args); + if(!$output->toBool()) return new Object(-1, 'fail_to_trash'); + } + $oDB->commit(); + $msg_code = 'success_trashed'; } $_SESSION['document_management'] = array(); diff --git a/modules/document/document.model.php b/modules/document/document.model.php index a3e8a1799..147f032ba 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -399,7 +399,6 @@ return $result; } - /** * @brief document의 확장 변수 키값을 가져오는 함수 * $form_include : 글 작성시에 필요한 확장변수의 input form 추가 여부 diff --git a/modules/document/lang/ko.lang.php b/modules/document/lang/ko.lang.php index 77a091390..e0d012cae 100644 --- a/modules/document/lang/ko.lang.php +++ b/modules/document/lang/ko.lang.php @@ -70,4 +70,29 @@ $lang->history = '히스토리'; $lang->about_use_history = '히스토리 기능의 사용여부를 지정합니다. 히스토리 기능을 사용할 경우 문서 수정시 이전 리비전을 기록하고 복원할 수 있습니다.'; $lang->trace_only = '흔적만 남김'; + + $lang->cmd_trash = "휴지통"; + $lang->cmd_restore = "복원"; + $lang->cmd_restore_all = "모두 복원"; + + $lang->in_trash = "휴지통"; + $lang->trash_nick_name = "삭제자 닉네임"; + $lang->trash_date = "삭제 날짜"; + $lang->trash_description = "설명"; + + // 관리자 페이지에서 휴지통의 검색할 대상 + $lang->search_target_trash_list = array( + 'title' => '제목', + 'content' => '내용', + 'user_id' => '아이디', + 'member_srl' => '회원번호', + 'user_name' => '사용자 이름', + 'nick_name' => '닉네임', + 'trash_member_srl' => '삭제자 회원번호', + 'trash_user_name' => '삭제자 사용자 이름', + 'trash_nick_name' => '삭제자 닉네임', + 'trash_date' => '삭제일', + 'trash_ipaddress' => '삭제자 IP 주소', + ); + ?> diff --git a/modules/document/queries/deleteTrash.xml b/modules/document/queries/deleteTrash.xml new file mode 100644 index 000000000..ec7dd9f79 --- /dev/null +++ b/modules/document/queries/deleteTrash.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/document/queries/getTrash.xml b/modules/document/queries/getTrash.xml new file mode 100644 index 000000000..b938c5017 --- /dev/null +++ b/modules/document/queries/getTrash.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/document/queries/getTrashList.xml b/modules/document/queries/getTrashList.xml new file mode 100644 index 000000000..07bda9c42 --- /dev/null +++ b/modules/document/queries/getTrashList.xml @@ -0,0 +1,29 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/document/queries/insertTrash.xml b/modules/document/queries/insertTrash.xml new file mode 100644 index 000000000..42d32c5af --- /dev/null +++ b/modules/document/queries/insertTrash.xml @@ -0,0 +1,17 @@ + + +
+ + + + + + + + + + + + + + diff --git a/modules/document/queries/updateCategoryCount.xml b/modules/document/queries/updateCategoryCount.xml index e0611c857..6a4ef0397 100644 --- a/modules/document/queries/updateCategoryCount.xml +++ b/modules/document/queries/updateCategoryCount.xml @@ -1,4 +1,4 @@ - +
diff --git a/modules/document/schemas/document_trash.xml b/modules/document/schemas/document_trash.xml new file mode 100644 index 000000000..ab8171432 --- /dev/null +++ b/modules/document/schemas/document_trash.xml @@ -0,0 +1,12 @@ +
+ + + + + + + + + + +
diff --git a/modules/document/tpl/checked_list.html b/modules/document/tpl/checked_list.html index e8a754eb6..482a64c85 100644 --- a/modules/document/tpl/checked_list.html +++ b/modules/document/tpl/checked_list.html @@ -52,6 +52,7 @@
+ {$lang->cmd_trash} {$lang->cmd_delete} {$lang->cmd_move} {$lang->cmd_copy} diff --git a/modules/document/tpl/document_list.html b/modules/document/tpl/document_list.html index 892fb39e6..6334736eb 100644 --- a/modules/document/tpl/document_list.html +++ b/modules/document/tpl/document_list.html @@ -55,10 +55,14 @@ {$no} isCarted())-->checked="checked"/> - - {$lang->cmd_save} + + + {$lang->cmd_save} + + {$oDocument->getTitle()} + - {$oDocument->getTitle()} + [{$lang->in_trash}] {$oDocument->getTitle()} diff --git a/modules/document/tpl/document_trash_list.html b/modules/document/tpl/document_trash_list.html new file mode 100644 index 000000000..3e8d108b9 --- /dev/null +++ b/modules/document/tpl/document_trash_list.html @@ -0,0 +1,73 @@ + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + checked="checked"/>--> + + + + + + + + + +
Total {number_format($total_count)}, Page {number_format($page)}/{number_format($total_page)}
{$lang->no}
{$lang->document}
{$lang->trash_nick_name}
{$lang->trash_date}
{$lang->ipaddress}
{$lang->trash_description}
{$lang->cmd_restore}
{$no} + {$oDocument->getTitle()} + + + [{$oDocument->getCommentCount()}] + + + + [{$oDocument->getTrackbackCount()}] + + {htmlspecialchars($oDocument->get('trash_nick_name'))}{zdate($oDocument->get('trash_date'), "Y-m-d H:i:s")}{$oDocument->get('ipaddress')}{$oDocument->get('trash_description')}{$lang->cmd_restore}
+ +
+ + + diff --git a/modules/document/tpl/header.html b/modules/document/tpl/header.html index 40d58b2c5..4744f8657 100644 --- a/modules/document/tpl/header.html +++ b/modules/document/tpl/header.html @@ -7,5 +7,6 @@
  • class="on">{$lang->document_list}
  • class="on">{$lang->cmd_module_config}
  • class="on">{$lang->cmd_declared_list}
  • +
  • class="on"{$lang->cmd_trash}
  • diff --git a/modules/document/tpl/js/document_admin.js b/modules/document/tpl/js/document_admin.js index f7187eb36..1b26f5383 100644 --- a/modules/document/tpl/js/document_admin.js +++ b/modules/document/tpl/js/document_admin.js @@ -116,11 +116,19 @@ function insertSelectedModule(id, module_srl, mid, browser_title) { function deleteByFilter(target_srl, filter) { var e = xGetElementById('target_srl'); - e.value= target_srl; + e.value = target_srl; var hF = xGetElementById("deleteForm"); procFilter(hF, filter); } +function executeFilterByTargetSrl(form_name, target_srl, filter) +{ + var e = xGetElementById('target_srl'); + e.value = target_srl; + var hF = xGetElementById(form_name); + procFilter(hF, filter); +} + function doDeleteExtraKey(module_srl, var_idx) { var fo_obj = xGetElementById('fo_delete'); fo_obj.module_srl.value = module_srl; @@ -136,3 +144,8 @@ function moveVar(type, module_srl, var_idx) { var response_tags = new Array('error','message'); exec_xml('document','procAdminMoveExtraVar', params, function() { location.reload(); }); } + +function completeRestoreTrash(ret_obj) { + alert(ret_obj['message']); + location.href = current_url; +}