diff --git a/modules/board/board.view.php b/modules/board/board.view.php
index e485839bd..2576a4aad 100644
--- a/modules/board/board.view.php
+++ b/modules/board/board.view.php
@@ -1149,6 +1149,17 @@ class BoardView extends Board
return $this->dispBoardMessage('msg_not_founded', 404);
}
+ // Check thread depth
+ $comment_config = ModuleModel::getModulePartConfig('comment', $this->module_srl);
+ if (isset($comment_config->max_thread_depth) && $comment_config->max_thread_depth > 0)
+ {
+ $parent_depth = CommentModel::getCommentDepth($parent_srl);
+ if ($parent_depth + 2 > $comment_config->max_thread_depth)
+ {
+ return $this->dispBoardMessage('msg_exceeds_max_thread_depth');
+ }
+ }
+
// Check allow comment
$oDocument = DocumentModel::getDocument($oSourceComment->get('document_srl'));
if(!$oDocument->allowComment())
diff --git a/modules/board/models/Features.php b/modules/board/models/Features.php
index 7e8dc1472..6bbc567ec 100644
--- a/modules/board/models/Features.php
+++ b/modules/board/models/Features.php
@@ -119,6 +119,7 @@ class Features
{
$features->comment->cancel_report = ($module_info->cancel_vote ?? 'N') === 'Y';
}
+ $features->comment->max_thread_depth = $comment_config->max_thread_depth ?? 0;
$features->comment->default_page = $comment_config->default_page ?? 'last';
return $features;
diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php
index a7d00de10..c7309197b 100644
--- a/modules/comment/comment.controller.php
+++ b/modules/comment/comment.controller.php
@@ -735,6 +735,17 @@ class CommentController extends Comment
$list_args->head = $parent->head;
$list_args->depth = $parent->depth + 1;
+ // Check max thread depth.
+ $comment_config = ModuleModel::getModulePartConfig('comment', $obj->module_srl);
+ if (isset($comment_config->max_thread_depth) && $comment_config->max_thread_depth > 0)
+ {
+ if ($list_args->depth + 1 > $comment_config->max_thread_depth)
+ {
+ $oDB->rollback();
+ return new BaseObject(-1, 'msg_exceeds_max_thread_depth');
+ }
+ }
+
// if the depth of comments is less than 2, execute insert.
if($list_args->depth < 2)
{
@@ -2041,6 +2052,7 @@ class CommentController extends Comment
{
$comment_config->comment_page_count = 10;
}
+ $comment_config->max_thread_depth = (int)Context::get('max_thread_depth') ?: 0;
$comment_config->default_page = Context::get('default_page');
if($comment_config->default_page !== 'first')
diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php
index ab309686f..2be007f07 100644
--- a/modules/comment/comment.model.php
+++ b/modules/comment/comment.model.php
@@ -246,6 +246,18 @@ class CommentModel extends Comment
return $result;
}
+ /**
+ * Get comment depth.
+ *
+ * @param int $comment_srl
+ * @return ?int
+ */
+ public static function getCommentDepth(int $comment_srl): ?int
+ {
+ $output = executeQuery('comment.getCommentDepth', ['comment_srl' => $comment_srl]);
+ return isset($output->data->depth) ? (int)$output->data->depth : null;
+ }
+
/**
* Get the total number of comments in corresponding with document_srl.
* @param int $document_srl
diff --git a/modules/comment/lang/en.php b/modules/comment/lang/en.php
index 1b2b14b20..273c5dfad 100644
--- a/modules/comment/lang/en.php
+++ b/modules/comment/lang/en.php
@@ -12,8 +12,11 @@ $lang->comment_default_page_first = 'First page';
$lang->comment_default_page_last = 'Last page';
$lang->about_comment_count = 'Set the number of comments to show on each page.';
$lang->about_comment_page_count = 'Set the number of pagination links to show at the bottom.';
+$lang->max_thread_depth = 'Maximum Thread Depth';
+$lang->about_max_thread_depth = '0: Unlimited, 1: No replies, 2 or more: Allow replies';
$lang->msg_cart_is_null = 'Please select an article to delete.';
$lang->msg_checked_comment_is_deleted = '%d comment(s) is(are) successfully deleted.';
+$lang->msg_exceeds_max_thread_depth = 'You have exceeded the maximum thread depth. Please leave a reply elsewhere in the thread.';
$lang->search_target_list['content'] = 'Content';
$lang->search_target_list['user_id'] = 'ID';
$lang->search_target_list['user_name'] = 'Name';
diff --git a/modules/comment/lang/ko.php b/modules/comment/lang/ko.php
index 1fb8e2adf..a5a6005ed 100644
--- a/modules/comment/lang/ko.php
+++ b/modules/comment/lang/ko.php
@@ -12,8 +12,11 @@ $lang->comment_default_page_first = '첫 페이지';
$lang->comment_default_page_last = '마지막 페이지';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고, 그 이상일 경우 페이지 번호를 표시해서 이동할 수 있게 합니다.';
$lang->about_comment_page_count = '하단에 표시할 페이지 링크 수를 설정할 수 있습니다.';
+$lang->max_thread_depth = '대댓글 최대 깊이';
+$lang->about_max_thread_depth = '0: 무제한, 1: 대댓글 금지, 2 이상: 대댓글 허용';
$lang->msg_cart_is_null = '삭제할 글을 선택해주세요.';
$lang->msg_checked_comment_is_deleted = '%d개의 댓글을 삭제했습니다.';
+$lang->msg_exceeds_max_thread_depth = '대댓글 최대 깊이를 초과했습니다. 다른 자리에 댓글을 남겨 주세요.';
$lang->search_target_list['content'] = '내용';
$lang->search_target_list['user_id'] = '아이디';
$lang->search_target_list['user_name'] = '이름';
diff --git a/modules/comment/queries/getCommentDepth.xml b/modules/comment/queries/getCommentDepth.xml
new file mode 100644
index 000000000..9748581b8
--- /dev/null
+++ b/modules/comment/queries/getCommentDepth.xml
@@ -0,0 +1,11 @@
+
+
{$lang->about_comment_page_count}
+{$lang->about_max_thread_depth}
+