diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index be3c3190e..b6885f8c4 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -510,10 +510,37 @@ class boardController extends board // generate comment controller object $oCommentController = getController('comment'); - $output = $oCommentController->deleteComment($comment_srl, $this->grant->manager); - if(!$output->toBool()) + if($this->module_info->comment_delete_message === 'yes') { - return $output; + $comment->content = ''; + $comment->status = 7; + $output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager); + } + elseif($this->module_info->comment_delete_message === 'only_commnet') + { + $childs = $oCommentModel->getChildComments($comment_srl); + if(count($childs) > 0) + { + $comment->content = ''; + $comment->status = 7; + $output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager); + } + else + { + $output = $oCommentController->deleteComment($comment_srl, $this->grant->manager, FALSE, $childs); + if(!$output->toBool()) + { + return $output; + } + } + } + else + { + $output = $oCommentController->deleteComment($comment_srl, $this->grant->manager); + if(!$output->toBool()) + { + return $output; + } } $this->add('mid', Context::get('mid')); diff --git a/modules/board/lang/en.php b/modules/board/lang/en.php index ce80ba2bb..e054500a1 100644 --- a/modules/board/lang/en.php +++ b/modules/board/lang/en.php @@ -42,3 +42,8 @@ $lang->about_hide_category = 'You can disable a category feature.'; $lang->protect_content = 'Protect contents'; $lang->about_protect_content = 'If there is any comment on document, document\'s owner cannot modify or delete that.'; $lang->msg_protect_content = 'You cannot modify or delete document which has any comment on it.'; +$lang->comment_delete_message = 'Leave Placeholder for Deleted Comment'; +$lang->about_comment_delete_message = 'When a comment is deleted, leave a placeholder saying that it has been deleted.'; +$lang->cmd_only_p_comment = 'Only if there are replies'; +$lang->cmd_all_comment_message = 'Always'; +$lang->cmd_do_not_massage = 'Never'; diff --git a/modules/board/lang/ko.php b/modules/board/lang/ko.php index be88e8b64..4251794f7 100644 --- a/modules/board/lang/ko.php +++ b/modules/board/lang/ko.php @@ -71,3 +71,10 @@ $lang->write_admin = '관리자작성'; $lang->revert_reason_update = '이 버전으로 되돌림'; $lang->document_force_to_move = '삭제시 휴지통으로 강제이동'; $lang->about_document_force_to_move = '게시글을 삭제시 휴지통으로 강제이동할지 않할지를 선택하는 옵션입니다.'; +$lang->comment_delete_message = '댓글자리 남김'; +$lang->about_comment_delete_message = '댓글 삭제시 완전히 삭제하지 않고 "삭제된 댓글"이라는 메시지를 남깁니다.'; +$lang->cmd_only_p_comment = '대댓글이 있는 경우에만 남김'; +$lang->cmd_all_comment_message = '모든댓글에 남김'; +$lang->cmd_do_not_massage = '남기지 않음'; +$lang->msg_delete_comment = '댓글이 삭제되었습니다.'; +$lang->msg_admin_delete_comment = '관리자에 의해 댓글이 삭제되었습니다.'; diff --git a/modules/board/skins/xedition/_comment.html b/modules/board/skins/xedition/_comment.html index e2fffcbbd..11155077a 100644 --- a/modules/board/skins/xedition/_comment.html +++ b/modules/board/skins/xedition/_comment.html @@ -25,7 +25,16 @@ - {$comment->getContent(false)} +
+ + {$lang->msg_delete_comment} + + {$lang->msg_admin_delete_comment} + +
+ + {$comment->getContent(false)} +
@@ -33,7 +42,7 @@
  • {$file->source_filename} [File Size:{FileHandler::filesize($file->file_size)}/Download:{number_format($file->download_count)}]
  • -

    +

    {$lang->cmd_vote}{$comment->get('voted_count')} {$lang->cmd_vote}{$comment->get('voted_count')} {$lang->cmd_vote_down}{$comment->get('blamed_count')} diff --git a/modules/board/tpl/board_insert.html b/modules/board/tpl/board_insert.html index bfad50a43..0e6977083 100644 --- a/modules/board/tpl/board_insert.html +++ b/modules/board/tpl/board_insert.html @@ -274,6 +274,18 @@

    {$lang->about_protect_regdate}

    +
    + +
    + +

    {$lang->about_comment_delete_message}

    +
    +
    +
    diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index cc32b1591..6dbcd0161 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -904,14 +904,75 @@ class commentController extends comment return $output; } + /** + * Fix comment the delete comment message + * @param object $obj + * @param bool $is_admin + * @return object + */ + function updateCommentByDelete($obj, $is_admin = FALSE) + { + $logged_info = Context::get('logged_info'); + + // begin transaction + $oDB = DB::getInstance(); + $oDB->begin(); + + // If the case manager to delete comments, it indicated that the administrator deleted. + if($is_admin === true && $obj->member_srl !== $logged_info->member_srl) + { + $obj->content = lang('msg_admin_delete_comment'); + $obj->status = 8; + } + else + { + $obj->content = lang('msg_delete_comment'); + } + $obj->member_srl = 0; + $output = executeQuery('comment.updateCommentByDelete', $obj); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + + // call a trigger by delete (after) + ModuleHandler::triggerCall('comment.updateCommentByDelete', 'after', $obj); + + // update the number of comments + $oCommentModel = getModel('comment'); + $comment_count = $oCommentModel->getCommentCount($obj->document_srl); + // only document is exists + if(isset($comment_count)) + { + // create the controller object of the document + $oDocumentController = getController('document'); + + // update comment count of the article posting + $output = $oDocumentController->updateCommentCount($obj->document_srl, $comment_count, NULL, FALSE); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + } + + $oDB->commit(); + + $output->add('document_srl', $obj->document_srl); + + return $output; + } + /** * Delete comment * @param int $comment_srl * @param bool $is_admin * @param bool $isMoveToTrash + * @param object $childs * @return object */ - function deleteComment($comment_srl, $is_admin = FALSE, $isMoveToTrash = FALSE) + function deleteComment($comment_srl, $is_admin = FALSE, $isMoveToTrash = FALSE, $childs = null) { // create the comment model object $oCommentModel = getModel('comment'); @@ -944,7 +1005,10 @@ class commentController extends comment } // check if child comment exists on the comment - $childs = $oCommentModel->getChildComments($comment_srl); + if(!$childs) + { + $childs = $oCommentModel->getChildComments($comment_srl); + } if(count($childs) > 0) { $deleteAllComment = TRUE; diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 1a2def9d5..a11679be4 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -248,14 +248,20 @@ class commentModel extends comment //check if module is using validation system $oCommentController = getController('comment'); - $using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); + $module_info = getModel('module')->getModuleInfoByDocumentSrl($document_srl); + $use_comment_massage = $module_info->comment_delete_message; + if($using_validation) { $args->status = 1; } + elseif($use_comment_massage == 'Y') + { + $args->status = 1; + } - $output = executeQuery('comment.getCommentCount', $args, NULL, 'master'); + $output = executeQuery('comment.getCommentCount', $args, NULL); $total_count = $output->data->count; return (int) $total_count; diff --git a/modules/comment/queries/getCommentCount.xml b/modules/comment/queries/getCommentCount.xml index 6a64300df..b426c47c6 100644 --- a/modules/comment/queries/getCommentCount.xml +++ b/modules/comment/queries/getCommentCount.xml @@ -10,5 +10,6 @@ + diff --git a/modules/comment/queries/getCommentPageList.xml b/modules/comment/queries/getCommentPageList.xml index eb0f747e2..e7b650b7a 100644 --- a/modules/comment/queries/getCommentPageList.xml +++ b/modules/comment/queries/getCommentPageList.xml @@ -8,14 +8,13 @@ - + - diff --git a/modules/comment/queries/updateCommentByDelete.xml b/modules/comment/queries/updateCommentByDelete.xml new file mode 100644 index 000000000..beb8e842e --- /dev/null +++ b/modules/comment/queries/updateCommentByDelete.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + +