Move non-member voting, vote canceling, and report canceling options from Board module to Document & Comment modules

This commit is contained in:
Kijin Sung 2023-07-05 22:27:17 +09:00
parent 103f5ce884
commit 3215631dfc
13 changed files with 454 additions and 192 deletions

View file

@ -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';

View file

@ -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 = '이동';

View file

@ -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.';

View file

@ -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 = '최고관리자가 작성한 글이나 댓글은 게시판 관리 권한이 있는 회원이라도 수정 또는 삭제할 수 없도록 합니다.';

View file

@ -318,30 +318,6 @@
<p class="x_help-block">{$lang->about_document_force_to_move}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->non_login_vote}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="non_login_vote_y" name="non_login_vote" value="Y" checked="checked"|cond="$module_info->non_login_vote == 'Y'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="non_login_vote_n" name="non_login_vote" value="N" checked="checked"|cond="$module_info->non_login_vote != 'Y'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_non_login_vote}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cancel_vote}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="cancel_vote_y" name="cancel_vote" value="Y" checked="checked"|cond="$module_info->cancel_vote == 'Y'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="cancel_vote_n" name="cancel_vote" value="N" checked="checked"|cond="$module_info->cancel_vote != 'Y'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_cancel_vote}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->filter_specialchars}</label>
<div class="x_controls">

View file

@ -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,11 +405,24 @@ 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))
{
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);

View file

@ -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

View file

@ -28,6 +28,20 @@
</select>
</div>
</div>
<div class="x_control-group">
<label for="use_comment_validation" class="x_control-label">{$lang->cmd_comment_validation}</label>
<div class="x_controls">
<label for="use_comment_validation_Y" class="x_inline">
<input type="radio" id="use_comment_validation_Y" name="use_comment_validation" value="Y" checked="checked"|cond="$comment_config->use_comment_validation === 'Y'">
{$lang->cmd_yes}
</label>
<label for="use_comment_validation_N" class="x_inline">
<input type="radio" id="use_comment_validation_N" name="use_comment_validation" value="N" checked="checked"|cond="$comment_config->use_comment_validation !== 'Y'">
{$lang->cmd_no}
</label>
<p class="x_help-inline">{$lang->about_comment_validation}</p>
</div>
</div>
<div class="x_control-group">
<label for="c_use_vote_up" class="x_control-label">{$lang->cmd_vote}</label>
<div class="x_controls">
@ -49,45 +63,35 @@
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{lang('document.allow_vote_from_same_ip')}</label>
<label class="x_control-label">{$lang->cmd_vote_config}</label>
<div class="x_controls">
<label for="c_allow_vote_from_same_ip_Y" class="x_inline">
<input type="radio" id="c_allow_vote_from_same_ip_Y" name="allow_vote_from_same_ip" value="Y" checked="checked"|cond="$comment_config->allow_vote_from_same_ip === 'Y'">
{$lang->cmd_yes}
<label for="c_allow_vote_from_same_ip" class="x_inline">
<input type="checkbox" id="c_allow_vote_from_same_ip" name="allow_vote_from_same_ip" value="Y" checked="checked"|cond="$comment_config->allow_vote_from_same_ip === 'Y'">
{lang('document.allow_vote_from_same_ip')}
</label>
<label for="c_allow_vote_from_same_ip_N" class="x_inline">
<input type="radio" id="c_allow_vote_from_same_ip_N" name="allow_vote_from_same_ip" value="N" checked="checked"|cond="$comment_config->allow_vote_from_same_ip !== 'Y'">
{$lang->cmd_no}
<label for="c_allow_vote_cancel" class="x_inline">
<input type="checkbox" id="c_allow_vote_cancel" name="allow_vote_cancel" value="Y" checked="checked"|cond="$comment_config->allow_vote_cancel === 'Y'">
{lang('document.allow_vote_cancel')}
</label>
<label for="c_allow_vote_non_member" class="x_inline">
<input type="checkbox" id="c_allow_vote_non_member" name="allow_vote_non_member" value="Y" checked="checked"|cond="$comment_config->allow_vote_non_member === 'Y'">
{lang('document.allow_vote_non_member')}
</label>
</div>
</div>
<div class="x_control-group">
<label for="use_vote_down" class="x_control-label">{lang('document.allow_declare_from_same_ip')}</label>
<label class="x_control-label">{$lang->cmd_declare_config}</label>
<div class="x_controls">
<label for="c_allow_declare_from_same_ip_Y" class="x_inline">
<input type="radio" id="c_allow_declare_from_same_ip_Y" name="allow_declare_from_same_ip" value="Y" checked="checked"|cond="$comment_config->allow_declare_from_same_ip === 'Y'">
{$lang->cmd_yes}
<label for="c_allow_declare_from_same_ip" class="x_inline">
<input type="checkbox" id="c_allow_declare_from_same_ip" name="allow_declare_from_same_ip" value="Y" checked="checked"|cond="$comment_config->allow_declare_from_same_ip === 'Y'">
{lang('document.allow_declare_from_same_ip')}
</label>
<label for="c_allow_declare_from_same_ip_N" class="x_inline">
<input type="radio" id="c_allow_declare_from_same_ip_N" name="allow_declare_from_same_ip" value="N" checked="checked"|cond="$comment_config->allow_declare_from_same_ip !== 'Y'">
{$lang->cmd_no}
<label for="c_allow_declare_cancel" class="x_inline">
<input type="checkbox" id="c_allow_declare_cancel" name="allow_declare_cancel" value="Y" checked="checked"|cond="$comment_config->allow_declare_cancel === 'Y'">
{lang('document.allow_declare_cancel')}
</label>
</div>
</div>
<div class="x_control-group">
<label for="use_comment_validation" class="x_control-label">{$lang->cmd_comment_validation}</label>
<div class="x_controls">
<label for="use_comment_validation_Y" class="x_inline">
<input type="radio" id="use_comment_validation_Y" name="use_comment_validation" value="Y" checked="checked"|cond="$comment_config->use_comment_validation === 'Y'">
{$lang->cmd_yes}
</label>
<label for="use_comment_validation_N" class="x_inline">
<input type="radio" id="use_comment_validation_N" name="use_comment_validation" value="N" checked="checked"|cond="$comment_config->use_comment_validation !== 'Y'">
{$lang->cmd_no}
</label>
<p class="x_help-inline">{$lang->about_comment_validation}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{lang('document.cmd_declared_message')}</label>
<div class="x_controls">

View file

@ -30,19 +30,7 @@ class DocumentController extends Document
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
$module_info = $this->module_info;
if(!$module_info->module_srl)
{
$module_info = ModuleModel::getModuleInfoByDocumentSrl($document_srl);
}
if($module_info->non_login_vote !== 'Y')
{
if(!Context::get('is_logged'))
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
}
// Check target document.
$oDocument = DocumentModel::getDocument($document_srl, false, false);
if(!$oDocument->isExists())
{
@ -52,11 +40,31 @@ class DocumentController extends Document
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
// Check if voting is enabled.
$document_config = ModuleModel::getModulePartConfig('document', $oDocument->get('module_srl'));
if($document_config->use_vote_up === 'N')
{
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
}
if(!Context::get('is_logged'))
{
if (isset($document_config->allow_vote_non_member))
{
if ($document_config->allow_vote_non_member !== 'Y')
{
throw new Rhymix\Framework\Exceptions\MustLogin;
}
}
else
{
$module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oDocument->get('module_srl'));
if (($module_info->non_login_vote ?? 'N') !== 'Y')
{
throw new Rhymix\Framework\Exceptions\MustLogin;
}
}
}
$point = 1;
$allow_same_ip = ($document_config->allow_vote_from_same_ip ?? 'N') === 'Y';
@ -77,23 +85,7 @@ class DocumentController extends Document
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
$module_info = $this->module_info;
if(!$module_info->module_srl)
{
$module_info = ModuleModel::getModuleInfoByDocumentSrl($document_srl);
}
if($module_info->non_login_vote !== 'Y')
{
if(!Context::get('is_logged'))
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
}
if($module_info->cancel_vote !== 'Y')
{
throw new Rhymix\Framework\Exception('failed_voted_cancel');
}
// Check target document.
$oDocument = DocumentModel::getDocument($document_srl, false, false);
if(!$oDocument->isExists())
{
@ -108,6 +100,41 @@ class DocumentController extends Document
throw new Rhymix\Framework\Exception('failed_voted_canceled');
}
// Check if voting and canceling are enabled.
$document_config = ModuleModel::getModulePartConfig('document', $oDocument->get('module_srl'));
$module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oDocument->get('module_srl'));
if (isset($document_config->allow_vote_cancel))
{
if ($document_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($document_config->allow_vote_non_member))
{
if ($document_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($document_srl, $oDocument, $point);
if(!$output->toBool())
@ -120,44 +147,19 @@ class DocumentController extends Document
return $output;
}
/**
* insert alias
* @param int $module_srl
* @param int $document_srl
* @param string $alias_title
* @return object
*/
function insertAlias($module_srl, $document_srl, $alias_title)
{
$args = new stdClass;
$args->alias_srl = getNextSequence();
$args->module_srl = $module_srl;
$args->document_srl = $document_srl;
$args->alias_title = urldecode($alias_title);
$query = "document.insertAlias";
$output = executeQuery($query, $args);
return $output;
}
/**
* Action to handle vote-up of the post (Down)
* @return Object
*/
function procDocumentVoteDown()
{
if($this->module_info->non_login_vote !== 'Y')
{
if(!Context::get('is_logged'))
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
}
$document_srl = Context::get('target_srl');
if(!$document_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
// Check target document.
$oDocument = DocumentModel::getDocument($document_srl, false, false);
if(!$oDocument->isExists())
{
@ -167,11 +169,31 @@ class DocumentController extends Document
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
// Check if voting is enabled.
$document_config = ModuleModel::getModulePartConfig('document', $oDocument->get('module_srl'));
if($document_config->use_vote_down === 'N')
{
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
}
if(!Context::get('is_logged'))
{
if (isset($document_config->allow_vote_non_member))
{
if ($document_config->allow_vote_non_member !== 'Y')
{
throw new Rhymix\Framework\Exceptions\MustLogin;
}
}
else
{
$module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oDocument->get('module_srl'));
if (($module_info->non_login_vote ?? 'N') !== 'Y')
{
throw new Rhymix\Framework\Exceptions\MustLogin;
}
}
}
$point = -1;
$allow_same_ip = ($document_config->allow_vote_from_same_ip ?? 'N') === 'Y';
@ -186,23 +208,13 @@ class DocumentController extends Document
function procDocumentVoteDownCancel()
{
if($this->module_info->non_login_vote !== 'Y')
{
if(!Context::get('is_logged'))
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
}
if($this->module_info->cancel_vote !== 'Y')
{
return new Rhymix\Framework\Exception('failed_voted_canceled');
}
$document_srl = Context::get('target_srl');
if(!$document_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
// Check target document.
$oDocument = DocumentModel::getDocument($document_srl, false, false);
if(!$oDocument->isExists())
{
@ -217,6 +229,41 @@ class DocumentController extends Document
throw new Rhymix\Framework\Exception('failed_blamed_canceled');
}
// Check if voting and canceling are enabled.
$document_config = ModuleModel::getModulePartConfig('document', $oDocument->get('module_srl'));
$module_info = $this->module_info ?: ModuleModel::getModuleInfoByModuleSrl($oDocument->get('module_srl'));
if (isset($document_config->allow_vote_cancel))
{
if ($document_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($document_config->allow_vote_non_member))
{
if ($document_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($document_srl, $oDocument, $point);
if(!$output->toBool())
@ -367,6 +414,7 @@ class DocumentController extends Document
throw new Rhymix\Framework\Exceptions\MustLogin;
}
// Check if the document exists and is accessible to the current user.
$document_srl = Context::get('target_srl');
if(!$document_srl)
{
@ -381,11 +429,24 @@ class DocumentController extends Document
{
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
$module_info = ModuleModel::getModuleInfoByDocumentSrl($document_srl);
if($module_info->cancel_vote !== 'Y')
// Check if canceling is allowed.
$document_config = ModuleModel::getModulePartConfig('document', $oDocument->get('module_srl'));
if (isset($document_config->allow_declare_cancel))
{
if ($document_config->allow_declare_cancel !== 'Y')
{
throw new Rhymix\Framework\Exception('failed_declared_cancel');
}
}
else
{
$module_info = ModuleModel::getModuleInfoByModuleSrl($oDocument->get('module_srl'));
if (($module_info->cancel_vote ?? 'N') !== 'Y')
{
throw new Rhymix\Framework\Exception('failed_declared_cancel');
}
}
if(Context::get('success_return_url'))
{
@ -423,6 +484,25 @@ class DocumentController extends Document
}
}
/**
* insert alias
* @param int $module_srl
* @param int $document_srl
* @param string $alias_title
* @return object
*/
function insertAlias($module_srl, $document_srl, $alias_title)
{
$args = new stdClass;
$args->alias_srl = getNextSequence();
$args->module_srl = $module_srl;
$args->document_srl = $document_srl;
$args->alias_title = urldecode($alias_title);
$query = "document.insertAlias";
$output = executeQuery($query, $args);
return $output;
}
/**
* Delete alias when module deleted
* @param int $module_srl
@ -3268,9 +3348,18 @@ Content;
$document_config->allow_vote_from_same_ip = Context::get('allow_vote_from_same_ip');
if(!$document_config->allow_vote_from_same_ip) $document_config->allow_vote_from_same_ip = 'N';
$document_config->allow_vote_cancel = Context::get('allow_vote_cancel');
if(!$document_config->allow_vote_cancel) $document_config->allow_vote_cancel = 'N';
$document_config->allow_vote_non_member = Context::get('allow_vote_non_member');
if(!$document_config->allow_vote_non_member) $document_config->allow_vote_non_member = 'N';
$document_config->allow_declare_from_same_ip = Context::get('allow_declare_from_same_ip');
if(!$document_config->allow_declare_from_same_ip) $document_config->allow_declare_from_same_ip = 'N';
$document_config->allow_declare_cancel = Context::get('allow_declare_cancel');
if(!$document_config->allow_declare_cancel) $document_config->allow_declare_cancel = 'N';
$document_config->declared_message = Context::get('declared_message');
if(!is_array($document_config->declared_message)) $document_config->declared_message = array();
$document_config->declared_message = array_values($document_config->declared_message);

View file

@ -174,10 +174,47 @@ class DocumentView extends Document
{
$document_config = new stdClass();
}
if(!isset($document_config->use_history)) $document_config->use_history = 'N';
if(!isset($document_config->use_history))
{
$document_config->use_history = 'N';
}
if(!isset($document_config->use_vote_up))
{
$document_config->use_vote_up = 'Y';
}
if(!isset($document_config->use_vote_down))
{
$document_config->use_vote_down = 'Y';
}
if(!isset($document_config->allow_vote_from_same_ip))
{
$document_config->allow_vote_from_same_ip = 'N';
}
if(!isset($document_config->allow_declare_from_same_ip))
{
$document_config->allow_declare_from_same_ip = 'N';
}
if ($current_module_srl)
{
$module_info = ModuleModel::getModuleInfoByModuleSrl($current_module_srl);
if (!isset($document_config->allow_vote_cancel))
{
$document_config->allow_vote_cancel = (($module_info->cancel_vote ?? 'N') === 'Y') ? 'Y' : 'N';
}
if (!isset($document_config->allow_vote_non_member))
{
$document_config->allow_vote_non_member = (($module_info->non_login_vote ?? 'N') === 'Y') ? 'Y' : 'N';
}
if (!isset($document_config->allow_declare_cancel))
{
$document_config->allow_declare_cancel = (($module_info->cancel_vote ?? 'N') === 'Y') ? 'Y' : 'N';
}
}
Context::set('document_config', $document_config);
$oTemplate = &TemplateHandler::getInstance();
$oTemplate = TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'document_module_config');
$obj = $tpl . $obj;

View file

@ -118,4 +118,7 @@ $lang->improper_document_reasons['privacy'] = 'Privacy issue.';
$lang->improper_document_reasons['others'] = 'Others (Write your own)';
$lang->about_improper_document_declare = 'Write here why you report this article as an improper document.';
$lang->allow_vote_from_same_ip = 'Allow voting from same IP';
$lang->allow_vote_non_member = 'Allow voting by non-members';
$lang->allow_vote_cancel = 'Allow vote cancellation';
$lang->allow_declare_from_same_ip = 'Allow reporting from same IP';
$lang->allow_declare_cancel = 'Allow report cancellation';

View file

@ -118,4 +118,7 @@ $lang->improper_document_reasons['privacy'] = '민감한 개인정보가 노출
$lang->improper_document_reasons['others'] = '기타(직접작성)';
$lang->about_improper_document_declare = '게시글을 신고하신 이유를 간단히 적어서 제출해주시면 관리자 검토 후 조치하겠습니다.';
$lang->allow_vote_from_same_ip = '동일 IP 추천 허용';
$lang->allow_vote_non_member = '비회원 추천 허용';
$lang->allow_vote_cancel = '추천 취소 허용';
$lang->allow_declare_from_same_ip = '동일 IP 신고 허용';
$lang->allow_declare_cancel = '신고 취소 허용';

View file

@ -38,28 +38,32 @@
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->allow_vote_from_same_ip}</label>
<label class="x_control-label">{$lang->cmd_vote_config}</label>
<div class="x_controls">
<label for="d_allow_vote_from_same_ip_Y" class="x_inline">
<input type="radio" id="d_allow_vote_from_same_ip_Y" name="allow_vote_from_same_ip" value="Y" checked="checked"|cond="$document_config->allow_vote_from_same_ip === 'Y'">
{$lang->cmd_yes}
<label for="d_allow_vote_from_same_ip" class="x_inline">
<input type="checkbox" id="d_allow_vote_from_same_ip" name="allow_vote_from_same_ip" value="Y" checked="checked"|cond="$document_config->allow_vote_from_same_ip === 'Y'">
{$lang->allow_vote_from_same_ip}
</label>
<label for="d_allow_vote_from_same_ip_N" class="x_inline">
<input type="radio" id="d_allow_vote_from_same_ip_N" name="allow_vote_from_same_ip" value="N" checked="checked"|cond="$document_config->allow_vote_from_same_ip !== 'Y'">
{$lang->cmd_no}
<label for="d_allow_vote_cancel" class="x_inline">
<input type="checkbox" id="d_allow_vote_cancel" name="allow_vote_cancel" value="Y" checked="checked"|cond="$document_config->allow_vote_cancel === 'Y'">
{$lang->allow_vote_cancel}
</label>
<label for="d_allow_vote_non_member" class="x_inline">
<input type="checkbox" id="d_allow_vote_non_member" name="allow_vote_non_member" value="Y" checked="checked"|cond="$document_config->allow_vote_non_member === 'Y'">
{$lang->allow_vote_non_member}
</label>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->allow_declare_from_same_ip}</label>
<label class="x_control-label">{$lang->cmd_declare_config}</label>
<div class="x_controls">
<label for="d_allow_declare_from_same_ip_Y" class="x_inline">
<input type="radio" id="d_allow_declare_from_same_ip_Y" name="allow_declare_from_same_ip" value="Y" checked="checked"|cond="$document_config->allow_declare_from_same_ip === 'Y'">
{$lang->cmd_yes}
<label for="d_allow_declare_from_same_ip" class="x_inline">
<input type="checkbox" id="d_allow_declare_from_same_ip" name="allow_declare_from_same_ip" value="Y" checked="checked"|cond="$document_config->allow_declare_from_same_ip === 'Y'">
{$lang->allow_declare_from_same_ip}
</label>
<label for="d_allow_declare_from_same_ip_N" class="x_inline">
<input type="radio" id="d_allow_declare_from_same_ip_N" name="allow_declare_from_same_ip" value="N" checked="checked"|cond="$document_config->allow_declare_from_same_ip !== 'Y'">
{$lang->cmd_no}
<label for="d_allow_declare_cancel" class="x_inline">
<input type="checkbox" id="d_allow_declare_cancel" name="allow_declare_cancel" value="Y" checked="checked"|cond="$document_config->allow_declare_cancel === 'Y'">
{$lang->allow_declare_cancel}
</label>
</div>
</div>