Enable customizing the number of comments/replies required to prevent editing or deleting a post

This commit is contained in:
Kijin Sung 2026-02-06 18:06:16 +09:00
parent 5a8c669c42
commit 2f8c4ca77d
8 changed files with 110 additions and 50 deletions

View file

@ -878,9 +878,10 @@ class BoardView extends Board
}
if ($this->module_info->protect_content === 'Y' || $this->module_info->protect_update_content === 'Y')
{
if($oDocument->get('comment_count') > 0 && $this->grant->manager == false)
$comment_limit = $this->module_info->protect_update_content_limit ?? 1;
if($oDocument->get('comment_count') >= $comment_limit && $this->grant->manager == false)
{
throw new Rhymix\Framework\Exception('msg_protect_update_content');
throw new Rhymix\Framework\Exception(sprintf(lang('msg_protect_update_content'), $comment_limit));
}
}
@ -1103,9 +1104,10 @@ class BoardView extends Board
if($this->module_info->protect_content == "Y" || $this->module_info->protect_delete_content == 'Y')
{
$comment_limit = $this->module_info->protect_delete_content_limit ?? 1;
if($oDocument->get('comment_count')>0 && $this->grant->manager == false)
{
throw new Rhymix\Framework\Exception('msg_protect_delete_content');
throw new Rhymix\Framework\Exception(sprintf(lang('msg_protect_delete_content'), $comment_limit));
}
}
@ -1299,10 +1301,11 @@ class BoardView extends Board
}
if($this->module_info->protect_update_comment === 'Y' && $this->grant->manager == false)
{
$childs_limit = $this->module_info->protect_update_comment_limit ?? 1;
$childs = CommentModel::getChildComments($comment_srl);
if(count($childs) > 0)
if(count($childs) >= $childs_limit)
{
throw new Rhymix\Framework\Exception('msg_board_update_protect_comment');
throw new Rhymix\Framework\Exception(sprintf(lang('msg_board_update_protect_comment'), $childs_limit));
}
}
@ -1387,10 +1390,11 @@ class BoardView extends Board
if($this->module_info->protect_delete_comment === 'Y' && $this->grant->manager == false)
{
$childs_limit = $this->module_info->protect_delete_comment_limit ?? 1;
$childs = CommentModel::getChildComments($comment_srl);
if(count($childs) > 0)
if(count($childs) >= $childs_limit)
{
throw new Rhymix\Framework\Exception('msg_board_delete_protect_comment');
throw new Rhymix\Framework\Exception(sprintf(lang('msg_board_delete_protect_comment'), $childs_limit));
}
}