diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 74fe643c5..279aa9b71 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -398,11 +398,27 @@ function deleteComments($document_srl) { // document model객체 생성 $oDocumentModel = &getModel('document'); + $oCommentModel = &getModel('comment'); // 권한이 있는지 확인 $oDocument = $oDocumentModel->getDocument($document_srl); if(!$oDocument->isExists() || !$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); + // 댓글 목록을 가져와서 일단 trigger만 실행 (일괄 삭제를 해야 하기에 최대한 처리 비용을 줄이기 위한 방법) + $args->document_srl = $document_srl; + $comments = executeQueryArray('comment.getAllComments',$args); + if($comments->data) { + foreach($comments->data as $key => $comment) { + // trigger 호출 (before) + $output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment); + if(!$output->toBool()) continue; + + // trigger 호출 (after) + $output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment); + if(!$output->toBool()) continue; + } + } + // 댓글 본문 삭제 $args->document_srl = $document_srl; $output = executeQuery('comment.deleteComments', $args); diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 66e47b6d4..e2d8ba3f2 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -153,7 +153,6 @@ function getCommentAllCount($module_srl) { $args->module_srl = $module_srl; $output = executeQuery('comment.getCommentCount', $args); - debugPrint($output); $total_count = $output->data->count; return (int)$total_count; diff --git a/modules/comment/queries/getAllComments.xml b/modules/comment/queries/getAllComments.xml new file mode 100644 index 000000000..14d0d1a35 --- /dev/null +++ b/modules/comment/queries/getAllComments.xml @@ -0,0 +1,11 @@ + + + + + + + + + + +