diff --git a/modules/pagemaker/comment.class.php b/modules/pagemaker/comment.class.php new file mode 100644 index 000000000..32fb0a91a --- /dev/null +++ b/modules/pagemaker/comment.class.php @@ -0,0 +1,32 @@ + diff --git a/modules/pagemaker/comment.controller.php b/modules/pagemaker/comment.controller.php new file mode 100644 index 000000000..577bc86a3 --- /dev/null +++ b/modules/pagemaker/comment.controller.php @@ -0,0 +1,215 @@ +document_srl; + if(!$document_srl) return new Object(-1,'msg_invalid_document'); + + // document model 객체 생성 + $oDocumentModel = &getModel('document'); + + // 원본글을 가져옴 + $document = $oDocumentModel->getDocument($document_srl); + + if($document_srl != $document->document_srl) return new Object(-1,'msg_invalid_document'); + if($document->lock_comment=='Y') return new Object(-1,'msg_invalid_request'); + + $oDB = &DB::getInstance(); + + $obj->comment_srl = $oDB->getNextSequence(); + $obj->list_order = $obj->comment_srl * -1; + if($obj->password) $obj->password = md5($obj->password); + + // 로그인 된 회원일 경우 회원의 정보를 입력 + if(Context::get('is_logged')) { + $logged_info = Context::get('logged_info'); + $obj->member_srl = $logged_info->member_srl; + $obj->user_name = $logged_info->user_name; + $obj->nick_name = $logged_info->nick_name; + $obj->email_address = $logged_info->email_address; + $obj->homepage = $logged_info->homepage; + } + + // 댓글을 입력 + $output = $oDB->executeQuery('comment.insertComment', $obj); + + // 입력에 이상이 없으면 해당 글의 댓글 수를 올림 + if(!$output->toBool()) return $output; + + // comment model객체 생성 + $oCommentModel = &getModel('comment'); + + // 해당 글의 전체 댓글 수를 구해옴 + $comment_count = $oCommentModel->getCommentCount($document_srl); + + // document의 controller 객체 생성 + $oDocumentController = &getController('document'); + + // 해당글의 댓글 수를 업데이트 + $output = $oDocumentController->updateCommentCount($document_srl, $comment_count); + + // 댓글의 권한을 부여 + $this->addGrant($obj->comment_srl); + + $output->add('comment_srl', $obj->comment_srl); + return $output; + } + + /** + * @brief 댓글 수정 + **/ + function updateComment($obj, $is_admin = false) { + // comment model 객체 생성 + $oCommentModel = &getModel('comment'); + + // 원본 데이터를 가져옴 + $source_obj = $oCommentModel->getComment($obj->comment_srl); + + // 권한이 있는지 확인 + if(!$is_admin && !$source_obj->is_granted) return new Object(-1, 'msg_not_permitted'); + + $oDB = &DB::getInstance(); + + if($obj->password) $obj->password = md5($obj->password); + + // 로그인 되어 있고 작성자와 수정자가 동일하면 수정자의 정보를 세팅 + if(Context::get('is_logged')) { + $logged_info = Context::get('logged_info'); + if($source_obj->member_srl == $logged_info->member_srl) { + $obj->member_srl = $logged_info->member_srl; + $obj->user_name = $logged_info->user_name; + $obj->nick_name = $logged_info->nick_name; + $obj->email_address = $logged_info->email_address; + $obj->homepage = $logged_info->homepage; + } + } + + // 로그인한 유저가 작성한 글인데 user_name이 없을 경우 + if($source_obj->member_srl && !$obj->user_name) { + $obj->member_srl = $source_obj->member_srl; + $obj->user_name = $source_obj->user_name; + $obj->nick_name = $source_obj->nick_name; + $obj->email_address = $source_obj->email_address; + $obj->homepage = $source_obj->homepage; + } + + // 업데이트 + $output = $oDB->executeQuery('comment.updateComment', $obj); + + $output->add('comment_srl', $obj->comment_srl); + return $output; + } + + /** + * @brief 댓글 삭제 + **/ + function deleteComment($comment_srl, $is_admin = false) { + // comment model 객체 생성 + $oCommentModel = &getModel('comment'); + + // 기존 댓글이 있는지 확인 + $comment = $oCommentModel->getComment($comment_srl); + if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); + $document_srl = $comment->document_srl; + + // 해당 댓글에 child가 있는지 확인 + $child_count = $oCommentModel->getChildCommentCount($comment_srl); + if($child_count>0) return new Object(-1, 'fail_to_delete_have_children'); + + // 권한이 있는지 확인 + if(!$is_admin && !$comment->is_granted) return new Object(-1, 'msg_not_permitted'); + + // 삭제 + $oDB = &DB::getInstance(); + + $args->comment_srl = $comment_srl; + $output = $oDB->executeQuery('comment.deleteComment', $args); + if(!$output->toBool()) return new Object(-1, 'msg_error_occured'); + + // 댓글 수를 구해서 업데이트 + $comment_count = $oCommentModel->getCommentCount($document_srl); + + // document의 controller 객체 생성 + $oDocumentController = &getController('document'); + + // 해당글의 댓글 수를 업데이트 + $output = $oDocumentController->updateCommentCount($document_srl, $comment_count); + + $output->add('document_srl', $document_srl); + return $output; + } + + /** + * @brief 특정 글의 모든 댓글 삭제 + **/ + function deleteComments($document_srl) { + // document model객체 생성 + $oDocumentModel = &getModel('document'); + + // 권한이 있는지 확인 + if(!$oDocumentModel->isGranted($document_srl)) return new Object(-1, 'msg_not_permitted'); + + // 삭제 + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('comment.deleteComments', $args); + return $output; + } + + /** + * @brief 특정 모듈의 모든 댓글 삭제 + **/ + function deleteModuleComments($module_srl) { + $oDB = &DB::getInstance(); + $args->module_srl = $module_srl; + $output = $oDB->executeQuery('comment.deleteModuleComments', $args); + return $output; + } + + /** + * @brief 관리자 페이지에서 선택된 댓글들을 삭제 + **/ + function procDeleteChecked() { + // 선택된 글이 없으면 오류 표시 + $cart = Context::get('cart'); + if(!$cart) return $this->stop('msg_cart_is_null'); + $comment_srl_list= explode('|@|', $cart); + $comment_count = count($comment_srl_list); + if(!$comment_count) return $this->stop('msg_cart_is_null'); + + // 글삭제 + for($i=0;$i<$comment_count;$i++) { + $comment_srl = trim($comment_srl_list[$i]); + if(!$comment_srl) continue; + + $this->deleteComment($comment_srl, true); + } + + $this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $comment_count) ); + } + } +?> diff --git a/modules/pagemaker/comment.model.php b/modules/pagemaker/comment.model.php new file mode 100644 index 000000000..54d8fe1c2 --- /dev/null +++ b/modules/pagemaker/comment.model.php @@ -0,0 +1,204 @@ +comment_srl = $comment_srl; + $output = $oDB->executeQuery('comment.getChildCommentCount', $args); + return (int)$output->data->count; + } + + /** + * @brief 댓글 가져오기 + **/ + function getComment($comment_srl, $is_admin = false) { + // DB에서 가져옴 + $oDB = &DB::getInstance(); + $args->comment_srl = $comment_srl; + $output = $oDB->executeQuery('comment.getComment', $args); + $comment = $output->data; + + // 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음 + $logged_info = Context::get('logged_info'); + + if($is_admin || $this->isGranted($comment_srl) || $comment->member_srl == $logged_info->member_srl) $comment->is_granted = true; + return $comment; + } + + /** + * @brief 여러개의 댓글들을 가져옴 (페이징 아님) + **/ + function getComments($comment_srl_list) { + if(is_array($comment_srl_list)) $comment_srls = implode(',',$comment_srl_list); + + $oDB = &DB::getInstance(); + $args->comment_srls = $comment_srls; + $output = $oDB->executeQuery('comment.getComments', $args); + return $output->data; + } + + /** + * @brief document_srl 에 해당하는 댓글의 전체 갯수를 가져옴 + **/ + function getCommentCount($document_srl) { + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('comment.getCommentCount', $args); + $total_count = $output->data->count; + return (int)$total_count; + } + + /** + * @brief document_srl에 해당하는 문서의 댓글 목록을 가져옴 + **/ + function getCommentList($document_srl, $is_admin = false) { + $oDB = &DB::getInstance(); + + $args->document_srl = $document_srl; + $args->list_order = 'list_order'; + $output = $oDB->executeQuery('comment.getCommentList', $args); + if(!$output->toBool()) return $output; + + $source_list= $output->data; + if(!is_array($source_list)) $source_list = array($source_list); + + // 댓글를 계층형 구조로 정렬 + $comment_count = count($source_list); + + $root = NULL; + $list = NULL; + + // 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음 + $logged_info = Context::get('logged_info'); + + for($i=$comment_count-1;$i>=0;$i--) { + $comment_srl = $source_list[$i]->comment_srl; + $parent_srl = $source_list[$i]->parent_srl; + $member_srl = $source_list[$i]->member_srl; + if(!$comment_srl) continue; + + if($is_admin || $this->isGranted($comment_srl) || $member_srl == $logged_info->member_srl) $source_list[$i]->is_granted = true; + + $list[$comment_srl] = $source_list[$i]; + + if($parent_srl) { + $list[$parent_srl]->child[] = &$list[$comment_srl]; + } else { + $root->child[] = &$list[$comment_srl]; + } + } + $this->_arrangeComment($comment_list, $root->child, 0); + return $comment_list; + } + + /** + * @brief 댓글을 계층형으로 재배치 + **/ + function _arrangeComment(&$comment_list, $list, $depth) { + if(!count($list)) return; + foreach($list as $key => $val) { + if($val->child) { + $tmp = $val; + $tmp->depth = $depth; + $comment_list[$tmp->comment_srl] = $tmp; + $this->_arrangeComment($comment_list,$val->child,$depth+1); + } else { + $val->depth = $depth; + $comment_list[$val->comment_srl] = $val; + } + } + } + + /** + * @brief 모든 댓글를 시간 역순으로 가져옴 (관리자용) + **/ + function getTotalCommentList($obj) { + + // DB 객체 생성 + $oDB = &DB::getInstance(); + + $query_id = 'comment.getTotalCommentList'; + + // 변수 설정 + $args->sort_index = 'list_order'; + $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; + + // 검색 옵션 정리 + $search_target = trim(Context::get('search_target')); + $search_keyword = trim(Context::get('search_keyword')); + if($search_target && $search_keyword) { + switch($search_target) { + case 'content' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_content = $search_keyword; + break; + case 'user_id' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_user_id = $search_keyword; + $query_id = 'comment.getTotalCommentListWithinMember'; + $args->sort_index = 'comments.list_order'; + break; + case 'user_name' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_user_name = $search_keyword; + break; + case 'nick_name' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_nick_name = $search_keyword; + break; + case 'email_address' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_email_address = $search_keyword; + break; + case 'homepage' : + if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + $args->s_homepage = $search_keyword; + break; + case 'regdate' : + $args->s_regdate = $search_keyword; + break; + case 'last_update' : + $args->s_last_upate = $search_keyword; + break; + case 'ipaddress' : + $args->s_ipaddress= $search_keyword; + break; + } + } + + // comment.getTotalCommentList 쿼리 실행 + $output = $oDB->executeQuery($query_id, $args); + + // 결과가 없거나 오류 발생시 그냥 return + if(!$output->toBool()||!count($output->data)) return $output; + + return $output; + } + } +?> diff --git a/modules/pagemaker/comment.view.php b/modules/pagemaker/comment.view.php new file mode 100644 index 000000000..06830649c --- /dev/null +++ b/modules/pagemaker/comment.view.php @@ -0,0 +1,64 @@ +page = Context::get('page'); ///< 페이지 + $args->list_count = 50; ///< 한페이지에 보여줄 글 수 + $args->page_count = 10; ///< 페이지 네비게이션에 나타날 페이지의 수 + + $args->sort_index = 'list_order'; ///< 소팅 값 + + // 목록 구함, comment->getCommentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다) + $oCommentModel = &getModel('comment'); + $output = $oCommentModel->getTotalCommentList($args); + + // 목록의 loop를 돌면서 mid를 구하기 위한 module_srl값을 구함 + $comment_count = count($output->data); + if($comment_count) { + foreach($output->data as $key => $val) { + $module_srl = $val->module_srl; + if(!in_array($module_srl, $module_srl_list)) $module_srl_list[] = $module_srl; + } + if(count($module_srl_list)) { + $oDB = &DB::getInstance(); + $args->module_srls = implode(',',$module_srl_list); + $mid_output = $oDB->executeQuery('module.getModuleInfoByModuleSrl', $args); + if($mid_output->data && !is_array($mid_output->data)) $mid_output->data = array($mid_output->data); + for($i=0;$idata);$i++) { + $mid_info = $mid_output->data[$i]; + $module_list[$mid_info->module_srl] = $mid_info; + } + } + } + + // 템플릿에 쓰기 위해서 comment_model::getTotalCommentList() 의 return object에 있는 값들을 세팅 + Context::set('total_count', $output->total_count); + Context::set('total_page', $output->total_page); + Context::set('page', $output->page); + Context::set('comment_list', $output->data); + Context::set('page_navigation', $output->page_navigation); + Context::set('module_list', $module_list); + + // 템플릿 지정 + $this->setTemplatePath($this->module_path.'tpl.admin'); + $this->setTemplateFile('comment_list'); + } + + } +?> diff --git a/modules/pagemaker/conf/info.xml b/modules/pagemaker/conf/info.xml new file mode 100644 index 000000000..f5f6d51a7 --- /dev/null +++ b/modules/pagemaker/conf/info.xml @@ -0,0 +1,11 @@ + + + 댓글 + comment + + 제로 + zero + 댓글 모듈 + comment + + diff --git a/modules/pagemaker/conf/module.xml b/modules/pagemaker/conf/module.xml new file mode 100644 index 000000000..9cd5a990b --- /dev/null +++ b/modules/pagemaker/conf/module.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/pagemaker/lang/ko.lang.php b/modules/pagemaker/lang/ko.lang.php new file mode 100644 index 000000000..880d6cdf4 --- /dev/null +++ b/modules/pagemaker/lang/ko.lang.php @@ -0,0 +1,26 @@ + + * @brief 댓글(comment) 모듈의 기본 언어팩 + **/ + + $lang->module = '모듈'; + + $lang->cmd_delete_checked_comment = '선택항목 삭제'; + + $lang->msg_cart_is_null = '삭제할 글을 선택해주세요'; + $lang->msg_checked_comment_is_deleted = '%d개의 댓글이 삭제되었습니다'; + + $lang->search_target_list = array( + 'content' => '내용', + 'user_id' => '아이디', + 'user_name' => '이름', + 'nick_name' => '닉네임', + 'email_address' => '이메일주소', + 'homepage' => '홈페이지', + 'regdate' => '등록일', + 'last_update' => '최근수정일 ', + 'ipaddress' => 'IP 주소', + ); +?> diff --git a/modules/pagemaker/queries/deleteComment.xml b/modules/pagemaker/queries/deleteComment.xml new file mode 100644 index 000000000..ce4b80e1f --- /dev/null +++ b/modules/pagemaker/queries/deleteComment.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/pagemaker/queries/deleteComments.xml b/modules/pagemaker/queries/deleteComments.xml new file mode 100644 index 000000000..30894de97 --- /dev/null +++ b/modules/pagemaker/queries/deleteComments.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/pagemaker/queries/deleteModuleComments.xml b/modules/pagemaker/queries/deleteModuleComments.xml new file mode 100644 index 000000000..98858b815 --- /dev/null +++ b/modules/pagemaker/queries/deleteModuleComments.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/pagemaker/queries/getChildCommentCount.xml b/modules/pagemaker/queries/getChildCommentCount.xml new file mode 100644 index 000000000..4686c279c --- /dev/null +++ b/modules/pagemaker/queries/getChildCommentCount.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/pagemaker/queries/getComment.xml b/modules/pagemaker/queries/getComment.xml new file mode 100644 index 000000000..17e595ad4 --- /dev/null +++ b/modules/pagemaker/queries/getComment.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/pagemaker/queries/getCommentCount.xml b/modules/pagemaker/queries/getCommentCount.xml new file mode 100644 index 000000000..6cdc97a29 --- /dev/null +++ b/modules/pagemaker/queries/getCommentCount.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/pagemaker/queries/getCommentList.xml b/modules/pagemaker/queries/getCommentList.xml new file mode 100644 index 000000000..2599b286b --- /dev/null +++ b/modules/pagemaker/queries/getCommentList.xml @@ -0,0 +1,14 @@ + + +
+ + + + + + + + + + + diff --git a/modules/pagemaker/queries/getComments.xml b/modules/pagemaker/queries/getComments.xml new file mode 100644 index 000000000..171fff6a0 --- /dev/null +++ b/modules/pagemaker/queries/getComments.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/pagemaker/queries/getTotalCommentList.xml b/modules/pagemaker/queries/getTotalCommentList.xml new file mode 100644 index 000000000..24e00dd87 --- /dev/null +++ b/modules/pagemaker/queries/getTotalCommentList.xml @@ -0,0 +1,24 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/modules/pagemaker/queries/getTotalCommentListWithinMember.xml b/modules/pagemaker/queries/getTotalCommentListWithinMember.xml new file mode 100644 index 000000000..dfe8841c1 --- /dev/null +++ b/modules/pagemaker/queries/getTotalCommentListWithinMember.xml @@ -0,0 +1,29 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/pagemaker/queries/insertComment.xml b/modules/pagemaker/queries/insertComment.xml new file mode 100644 index 000000000..7ecaa5c4d --- /dev/null +++ b/modules/pagemaker/queries/insertComment.xml @@ -0,0 +1,21 @@ + + +
+ + + + + + + + + + + + + + + + + + diff --git a/modules/pagemaker/queries/updateComment.xml b/modules/pagemaker/queries/updateComment.xml new file mode 100644 index 000000000..e263590ac --- /dev/null +++ b/modules/pagemaker/queries/updateComment.xml @@ -0,0 +1,20 @@ + + +
+ + + + + + + + + + + + + + + + + diff --git a/modules/pagemaker/schemas/comments.xml b/modules/pagemaker/schemas/comments.xml new file mode 100644 index 000000000..3073138ba --- /dev/null +++ b/modules/pagemaker/schemas/comments.xml @@ -0,0 +1,18 @@ +
+ + + + + + + + + + + + + + + + +
diff --git a/modules/pagemaker/tpl.admin/comment_list.html b/modules/pagemaker/tpl.admin/comment_list.html new file mode 100644 index 000000000..f069651aa --- /dev/null +++ b/modules/pagemaker/tpl.admin/comment_list.html @@ -0,0 +1,83 @@ + + + +
+ {$lang->total_count} : {number_format($total_count)}, + {$lang->page_count} : {number_format($page)} / {number_format($total_page)} +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
{$lang->no}{$lang->module}{$lang->user_name}{$lang->content}{$lang->date}{$lang->last_update}{$lang->ipaddress}{$lang->cmd_move}
{$no}{$module_list[$val->module_srl]->browser_title}{$val->user_name}{$val->content}{zdate($val->regdate,"Y-m-d")}{zdate($val->last_upgdate,"Y-m-d")}{$val->ipaddress}{$lang->cmd_move}
+
+ + +
+ +
+ +
+ + +
+
+ + + + +
+ + + + +
+
+
+ + + +
+ [{$lang->first_page}] + + + + {$page_no} + + [{$page_no}] + + + + [{$lang->last_page}] +
diff --git a/modules/pagemaker/tpl.admin/filter/delete_checked.xml b/modules/pagemaker/tpl.admin/filter/delete_checked.xml new file mode 100644 index 000000000..d2f074110 --- /dev/null +++ b/modules/pagemaker/tpl.admin/filter/delete_checked.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + + +