diff --git a/common/lang/en.php b/common/lang/en.php
index 85bbc44ef..c735d68fa 100644
--- a/common/lang/en.php
+++ b/common/lang/en.php
@@ -31,6 +31,8 @@ $lang->cmd_vote = 'Upvote';
$lang->cmd_vote_down = 'Downvote';
$lang->cmd_declare = 'Report';
$lang->cmd_cancel_declare = 'Cancel Report';
+$lang->cmd_vote_config = 'Voting Configuration';
+$lang->cmd_declare_config = 'Reporting Configuration';
$lang->cmd_declared_list = 'Reported List';
$lang->cmd_copy = 'Copy';
$lang->cmd_move = 'Move';
diff --git a/common/lang/ko.php b/common/lang/ko.php
index 713b7c045..0f27231c7 100644
--- a/common/lang/ko.php
+++ b/common/lang/ko.php
@@ -33,6 +33,8 @@ $lang->cmd_declare = '신고';
$lang->cmd_cancel_declare = '신고 취소';
$lang->cmd_cancel_vote = '추천 취소';
$lang->cmd_cancel_vote_down = '비추천 취소';
+$lang->cmd_vote_config = '추천 설정';
+$lang->cmd_declare_config = '신고 설정';
$lang->cmd_declared_list = '신고 목록';
$lang->cmd_copy = '복사';
$lang->cmd_move = '이동';
diff --git a/modules/board/lang/en.php b/modules/board/lang/en.php
index 13d64d709..4d20938ec 100644
--- a/modules/board/lang/en.php
+++ b/modules/board/lang/en.php
@@ -60,7 +60,6 @@ $lang->protect_content = 'Protect Content';
$lang->protect_comment = 'Protect Comment';
$lang->protect_admin_content = 'Protect Admin Content';
$lang->protect_regdate = 'Update/Delete Time Limit';
-$lang->cancel_vote = 'Vote Cancellation';
$lang->filter_specialchars = 'Block Abuse of Unicode Symbols';
$lang->document_length_limit = 'Limit Document Size';
$lang->comment_length_limit = 'Limit Comment Size';
@@ -68,12 +67,9 @@ $lang->about_document_length_limit = 'Restrict documents that are too large. Thi
$lang->about_comment_length_limit = 'Restrict comments that are too large.';
$lang->update_order_on_comment = 'Update Document on New Comment';
$lang->about_update_order_on_comment = 'When a new comment is posted, update the update timestamp of the parent document. This is needed for forums.';
-$lang->non_login_vote = 'Allow guest votes';
-$lang->about_cancel_vote = 'Allow users to cancel their votes';
$lang->about_filter_specialchars = 'Prevent use of excessive Unicode accents, RLO characters, and other symbols that hinder readability.';
$lang->document_force_to_move = 'Delete to Trash';
$lang->about_document_force_to_move = 'When a document is deleted, move to Trash instead of deleting it permamently.';
-$lang->about_non_login_vote = 'Allow users who are not logged in to vote on articles.';
$lang->about_protect_regdate = 'Prevent updating or deleting a document or comment after a certain amount of time has passed. (Unit: day)';
$lang->about_protect_content = 'Prevent updating a document if there are comments on it.';
$lang->about_protect_admin_content = 'Prevent updating or deleting a document or comment written by the administrator, even by a user who is permitted to manage the board.';
diff --git a/modules/board/lang/ko.php b/modules/board/lang/ko.php
index 1739809a2..d15453650 100644
--- a/modules/board/lang/ko.php
+++ b/modules/board/lang/ko.php
@@ -61,7 +61,6 @@ $lang->protect_content = '글 보호 기능';
$lang->protect_comment = '댓글 보호 기능';
$lang->protect_admin_content = '최고관리자 보호 기능';
$lang->protect_regdate = '기간 제한 기능';
-$lang->cancel_vote = '추천/비추천/신고 취소 허용';
$lang->filter_specialchars = '유니코드 특수문자 오남용 금지';
$lang->document_length_limit = '문서 길이 제한';
$lang->comment_length_limit = '댓글 길이 제한';
@@ -69,10 +68,7 @@ $lang->about_document_length_limit = '지나치게 용량이 큰 글을 작성
$lang->about_comment_length_limit = '지나치게 용량이 큰 댓글을 작성하지 못하도록 합니다.';
$lang->update_order_on_comment = '댓글 작성시 글 수정 시각 갱신';
$lang->about_update_order_on_comment = '댓글이 작성되면 해당 글의 수정 시각을 갱신합니다. 포럼형 게시판, 최근 댓글 표시 기능 등에 필요합니다.';
-$lang->non_login_vote = '비회원 추천 허용';
-$lang->about_cancel_vote = '추천 비추천 신고를 취소할 수 있습니다.';
$lang->about_filter_specialchars = '가독성에 악영향을 주는 과도한 유니코드 악센트 기호의 조합, RLO 문자 등의 사용을 금지합니다.';
-$lang->about_non_login_vote = '로그인하지 않은 방문자도 추천할 수 있도록 합니다.';
$lang->about_protect_regdate = '글이나 댓글을 작성한 후 일정 기간이 지나면 수정 또는 삭제할 수 없도록 합니다. (단위 : day)';
$lang->about_protect_content = '댓글이 달린 글은 수정 또는 삭제할 수 없도록 합니다.';
$lang->about_protect_admin_content = '최고관리자가 작성한 글이나 댓글은 게시판 관리 권한이 있는 회원이라도 수정 또는 삭제할 수 없도록 합니다.';
diff --git a/modules/board/tpl/board_insert.html b/modules/board/tpl/board_insert.html
index dbed3cf23..b3ff9bba0 100644
--- a/modules/board/tpl/board_insert.html
+++ b/modules/board/tpl/board_insert.html
@@ -318,30 +318,6 @@
{$lang->about_document_force_to_move}
-
-
-
-
-
-
{$lang->about_non_login_vote}
-
-
-
-
-
-
-
-
{$lang->about_cancel_vote}
-
-
diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php
index c655a4494..d2e8c986b 100644
--- a/modules/comment/comment.controller.php
+++ b/modules/comment/comment.controller.php
@@ -11,34 +11,19 @@
*/
class CommentController extends Comment
{
- /**
- * Initialization
- * @return void
- */
- function init()
- {
-
- }
-
/**
* Action to handle recommendation votes on comments (Up)
* @return Object
*/
function procCommentVoteUp()
{
- if($this->module_info->non_login_vote !== 'Y')
- {
- if(!Context::get('is_logged'))
- {
- throw new Rhymix\Framework\Exceptions\NotPermitted;
- }
- }
-
$comment_srl = Context::get('target_srl');
if(!$comment_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
+
+ // Check target comment.
$oComment = CommentModel::getComment($comment_srl);
if(!$oComment->isExists())
{
@@ -48,11 +33,31 @@ class CommentController extends Comment
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
+
+ // Check if voting is enabled.
$comment_config = ModuleModel::getModulePartConfig('comment', $oComment->get('module_srl'));
if($comment_config->use_vote_up === 'N')
{
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
}
+ if(!Context::get('is_logged'))
+ {
+ if (isset($comment_config->allow_vote_non_member))
+ {
+ if ($comment_config->allow_vote_non_member !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ else
+ {
+ $module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
+ if (($module_info->non_login_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ }
$point = 1;
$allow_same_ip = ($comment_config->allow_vote_from_same_ip ?? 'N') === 'Y';
@@ -63,19 +68,13 @@ class CommentController extends Comment
function procCommentVoteUpCancel()
{
- if($this->module_info->non_login_vote !== 'Y')
- {
- if(!Context::get('is_logged'))
- {
- throw new Rhymix\Framework\Exceptions\NotPermitted;
- }
- }
-
$comment_srl = Context::get('target_srl');
if(!$comment_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
+
+ // Check target comment.
$oComment = CommentModel::getComment($comment_srl);
if(!$oComment->isExists())
{
@@ -90,8 +89,47 @@ class CommentController extends Comment
throw new Rhymix\Framework\Exception('failed_voted_canceled');
}
+ // Check if voting and canceling are enabled.
+ $comment_config = ModuleModel::getModulePartConfig('comment', $oComment->get('module_srl'));
+ $module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
+ if (isset($comment_config->allow_vote_cancel))
+ {
+ if ($comment_config->allow_vote_cancel !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\FeatureDisabled;
+ }
+ }
+ else
+ {
+ if (($module_info->cancel_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\FeatureDisabled;
+ }
+ }
+ if(!Context::get('is_logged'))
+ {
+ if (isset($comment_config->allow_vote_non_member))
+ {
+ if ($comment_config->allow_vote_non_member !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ else
+ {
+ if (($module_info->non_login_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ }
+
$point = 1;
$output = $this->updateVotedCountCancel($comment_srl, $oComment, $point);
+ if(!$output->toBool())
+ {
+ return $output;
+ }
$output = new BaseObject();
$output->setMessage('success_voted_canceled');
@@ -106,19 +144,13 @@ class CommentController extends Comment
*/
function procCommentVoteDown()
{
- if($this->module_info->non_login_vote !== 'Y')
- {
- if(!Context::get('is_logged'))
- {
- throw new Rhymix\Framework\Exceptions\NotPermitted;
- }
- }
-
$comment_srl = Context::get('target_srl');
if(!$comment_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
+
+ // Check target comment.
$oComment = CommentModel::getComment($comment_srl);
if(!$oComment->isExists())
{
@@ -128,11 +160,31 @@ class CommentController extends Comment
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
+
+ // Check if voting is enabled.
$comment_config = ModuleModel::getModulePartConfig('comment', $oComment->get('module_srl'));
if($comment_config->use_vote_down === 'N')
{
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
}
+ if(!Context::get('is_logged'))
+ {
+ if (isset($comment_config->allow_vote_non_member))
+ {
+ if ($comment_config->allow_vote_non_member !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ else
+ {
+ $module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
+ if (($module_info->non_login_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ }
$point = -1;
$allow_same_ip = ($comment_config->allow_vote_from_same_ip ?? 'N') === 'Y';
@@ -143,19 +195,13 @@ class CommentController extends Comment
function procCommentVoteDownCancel()
{
- if($this->module_info->non_login_vote !== 'Y')
- {
- if(!Context::get('is_logged'))
- {
- throw new Rhymix\Framework\Exceptions\NotPermitted;
- }
- }
-
$comment_srl = Context::get('target_srl');
if(!$comment_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
+
+ // Check target comment.
$oComment = CommentModel::getComment($comment_srl);
if(!$oComment->isExists())
{
@@ -170,8 +216,47 @@ class CommentController extends Comment
throw new Rhymix\Framework\Exception('failed_blamed_canceled');
}
+ // Check if voting and canceling are enabled.
+ $comment_config = ModuleModel::getModulePartConfig('comment', $oComment->get('module_srl'));
+ $module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
+ if (isset($comment_config->allow_vote_cancel))
+ {
+ if ($comment_config->allow_vote_cancel !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\FeatureDisabled;
+ }
+ }
+ else
+ {
+ if (($module_info->cancel_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\FeatureDisabled;
+ }
+ }
+ if(!Context::get('is_logged'))
+ {
+ if (isset($comment_config->allow_vote_non_member))
+ {
+ if ($comment_config->allow_vote_non_member !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ else
+ {
+ if (($module_info->non_login_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exceptions\MustLogin;
+ }
+ }
+ }
+
$point = -1;
$output = $this->updateVotedCountCancel($comment_srl, $oComment, $point);
+ if(!$output->toBool())
+ {
+ return $output;
+ }
$output = new BaseObject();
$output->setMessage('success_blamed_canceled');
@@ -305,6 +390,7 @@ class CommentController extends Comment
throw new Rhymix\Framework\Exceptions\MustLogin;
}
+ // Check if the comment exists and is accessible to the current user.
$comment_srl = Context::get('target_srl');
if (!$comment_srl)
{
@@ -319,10 +405,23 @@ class CommentController extends Comment
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
- $module_info = ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
- if ($module_info->cancel_vote !== 'Y')
+
+ // Check if canceling is allowed.
+ $comment_config = ModuleModel::getModulePartConfig('comment', $oComment->get('module_srl'));
+ if (isset($comment_config->allow_declare_cancel))
{
- throw new Rhymix\Framework\Exception('failed_declared_cancel');
+ if ($comment_config->allow_declare_cancel !== 'Y')
+ {
+ throw new Rhymix\Framework\Exception('failed_declared_cancel');
+ }
+ }
+ else
+ {
+ $module_info = ModuleModel::getModuleInfoByModuleSrl($oComment->get('module_srl'));
+ if (($module_info->cancel_vote ?? 'N') !== 'Y')
+ {
+ throw new Rhymix\Framework\Exception('failed_declared_cancel');
+ }
}
if (Context::get('success_return_url'))
@@ -1949,9 +2048,18 @@ class CommentController extends Comment
$comment_config->allow_vote_from_same_ip = Context::get('allow_vote_from_same_ip');
if(!$comment_config->allow_vote_from_same_ip) $comment_config->allow_vote_from_same_ip = 'N';
+ $comment_config->allow_vote_cancel = Context::get('allow_vote_cancel');
+ if(!$comment_config->allow_vote_cancel) $comment_config->allow_vote_cancel = 'N';
+
+ $comment_config->allow_vote_non_member = Context::get('allow_vote_non_member');
+ if(!$comment_config->allow_vote_non_member) $comment_config->allow_vote_non_member = 'N';
+
$comment_config->allow_declare_from_same_ip = Context::get('allow_declare_from_same_ip');
if(!$comment_config->allow_declare_from_same_ip) $comment_config->allow_declare_from_same_ip = 'N';
+ $comment_config->allow_declare_cancel = Context::get('allow_declare_cancel');
+ if(!$comment_config->allow_declare_cancel) $comment_config->allow_declare_cancel = 'N';
+
$comment_config->declared_message = Context::get('declared_message');
if(!is_array($comment_config->declared_message)) $comment_config->declared_message = array();
$comment_config->declared_message = array_values($comment_config->declared_message);
diff --git a/modules/comment/comment.view.php b/modules/comment/comment.view.php
index fb5a1c62c..87f4226dd 100644
--- a/modules/comment/comment.view.php
+++ b/modules/comment/comment.view.php
@@ -44,6 +44,48 @@ class CommentView extends Comment
// get the comment configuration
$comment_config = CommentModel::getCommentConfig($current_module_srl);
+ if(!$comment_config)
+ {
+ $comment_config = new stdClass();
+ }
+ if(!isset($comment_config->cmd_comment_validation))
+ {
+ $comment_config->cmd_comment_validation = 'N';
+ }
+ if(!isset($comment_config->use_vote_up))
+ {
+ $comment_config->use_vote_up = 'Y';
+ }
+ if(!isset($comment_config->use_vote_down))
+ {
+ $comment_config->use_vote_down = 'Y';
+ }
+ if(!isset($comment_config->allow_vote_from_same_ip))
+ {
+ $comment_config->allow_vote_from_same_ip = 'N';
+ }
+ if(!isset($comment_config->allow_declare_from_same_ip))
+ {
+ $comment_config->allow_declare_from_same_ip = 'N';
+ }
+
+ if ($current_module_srl)
+ {
+ $module_info = ModuleModel::getModuleInfoByModuleSrl($current_module_srl);
+ if (!isset($comment_config->allow_vote_cancel))
+ {
+ $comment_config->allow_vote_cancel = (($module_info->cancel_vote ?? 'N') === 'Y') ? 'Y' : 'N';
+ }
+ if (!isset($comment_config->allow_vote_non_member))
+ {
+ $comment_config->allow_vote_non_member = (($module_info->non_login_vote ?? 'N') === 'Y') ? 'Y' : 'N';
+ }
+ if (!isset($comment_config->allow_declare_cancel))
+ {
+ $comment_config->allow_declare_cancel = (($module_info->cancel_vote ?? 'N') === 'Y') ? 'Y' : 'N';
+ }
+ }
+
Context::set('comment_config', $comment_config);
// get a group list
diff --git a/modules/comment/tpl/comment_module_config.html b/modules/comment/tpl/comment_module_config.html
index 1b97616cd..6a4cdac7d 100644
--- a/modules/comment/tpl/comment_module_config.html
+++ b/modules/comment/tpl/comment_module_config.html
@@ -28,6 +28,20 @@