mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Add options to allow voting and reporting from the same IP as the author of a document or comment
This commit is contained in:
parent
d285a90e88
commit
60ed013915
6 changed files with 106 additions and 30 deletions
|
|
@ -55,7 +55,8 @@ class CommentController extends Comment
|
|||
}
|
||||
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCount($comment_srl, $point);
|
||||
$allow_same_ip = ($comment_config->allow_vote_from_same_ip ?? 'N') === 'Y';
|
||||
$output = $this->updateVotedCount($comment_srl, $point, $allow_same_ip);
|
||||
$this->add('voted_count', $output->get('voted_count'));
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -134,7 +135,8 @@ class CommentController extends Comment
|
|||
}
|
||||
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCount($comment_srl, $point);
|
||||
$allow_same_ip = ($comment_config->allow_vote_from_same_ip ?? 'N') === 'Y';
|
||||
$output = $this->updateVotedCount($comment_srl, $point, $allow_same_ip);
|
||||
$this->add('blamed_count', $output->get('blamed_count'));
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -1461,9 +1463,10 @@ class CommentController extends Comment
|
|||
* Increase vote-up counts of the comment
|
||||
* @param int $comment_srl
|
||||
* @param int $point
|
||||
* @param bool $allow_same_ip
|
||||
* @return Object
|
||||
*/
|
||||
function updateVotedCount($comment_srl, $point = 1)
|
||||
function updateVotedCount($comment_srl, $point = 1, $allow_same_ip = false)
|
||||
{
|
||||
if($point > 0)
|
||||
{
|
||||
|
|
@ -1484,9 +1487,8 @@ class CommentController extends Comment
|
|||
$oComment = CommentModel::getComment($comment_srl);
|
||||
|
||||
// Pass if the author's IP address is as same as visitor's.
|
||||
if($oComment->get('ipaddress') == \RX_CLIENT_IP)
|
||||
if(!$allow_same_ip && $oComment->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
{
|
||||
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||
return new BaseObject(-1, $failed_voted);
|
||||
}
|
||||
|
||||
|
|
@ -1628,9 +1630,11 @@ class CommentController extends Comment
|
|||
$oComment = CommentModel::getComment($comment_srl);
|
||||
|
||||
// failed if both ip addresses between author's and the current user are same.
|
||||
if($oComment->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
$module_srl = $oComment->get('module_srl');
|
||||
$comment_config = ModuleModel::getModulePartConfig('comment', $module_srl);
|
||||
$allow_same_ip = ($comment_config->allow_declare_from_same_ip ?? 'N') === 'Y';
|
||||
if(!$allow_same_ip && $oComment->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
{
|
||||
$_SESSION['declared_comment'][$comment_srl] = FALSE;
|
||||
return new BaseObject(-1, 'failed_declared');
|
||||
}
|
||||
|
||||
|
|
@ -1703,8 +1707,6 @@ class CommentController extends Comment
|
|||
|
||||
// Send message to admin
|
||||
$message_targets = array();
|
||||
$module_srl = $oComment->get('module_srl');
|
||||
$comment_config = ModuleModel::getModulePartConfig('comment', $module_srl);
|
||||
if ($comment_config->declared_message && in_array('admin', $comment_config->declared_message))
|
||||
{
|
||||
$output = executeQueryArray('member.getAdmins', new stdClass);
|
||||
|
|
@ -1944,6 +1946,12 @@ class CommentController extends Comment
|
|||
$comment_config->use_vote_down = 'Y';
|
||||
}
|
||||
|
||||
$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_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->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);
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="use_vote_up" class="x_control-label">{$lang->cmd_vote}</label>
|
||||
<label for="c_use_vote_up" class="x_control-label">{$lang->cmd_vote}</label>
|
||||
<div class="x_controls">
|
||||
<select name="use_vote_up" id="use_vote_up">
|
||||
<select name="use_vote_up" id="c_use_vote_up">
|
||||
<option value="Y" selected="selected"|cond="$comment_config->use_vote_up=='Y'">{$lang->use}</option>
|
||||
<option value="S" selected="selected"|cond="$comment_config->use_vote_up=='S'">{$lang->use_and_display}</option>
|
||||
<option value="N" selected="selected"|cond="$comment_config->use_vote_up=='N'">{$lang->notuse}</option>
|
||||
|
|
@ -39,22 +39,52 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="use_vote_down" class="x_control-label">{$lang->cmd_vote_down}</label>
|
||||
<label for="c_use_vote_down" class="x_control-label">{$lang->cmd_vote_down}</label>
|
||||
<div class="x_controls">
|
||||
<select name="use_vote_down" id="use_vote_down">
|
||||
<select name="use_vote_down" id="c_use_vote_down">
|
||||
<option value="Y" selected="selected"|cond="$comment_config->use_vote_down=='Y'">{$lang->use}</option>
|
||||
<option value="S" selected="selected"|cond="$comment_config->use_vote_down=='S'">{$lang->use_and_display}</option>
|
||||
<option value="N" selected="selected"|cond="$comment_config->use_vote_down=='N'">{$lang->notuse}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{lang('document.allow_vote_from_same_ip')}</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="use_vote_down" class="x_control-label">{lang('document.allow_declare_from_same_ip')}</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>
|
||||
<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>
|
||||
</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">
|
||||
<select name="use_comment_validation" id="use_comment_validation">
|
||||
<option value="N" selected="selected"|cond="$comment_config->use_comment_validation=='N'">{$lang->notuse}</option>
|
||||
<option value="Y" selected="selected"|cond="$comment_config->use_comment_validation=='Y'">{$lang->use}</option>
|
||||
</select>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ class DocumentController extends Document
|
|||
}
|
||||
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCount($document_srl, $point);
|
||||
$allow_same_ip = ($document_config->allow_vote_from_same_ip ?? 'N') === 'Y';
|
||||
$output = $this->updateVotedCount($document_srl, $point, $allow_same_ip);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
|
|
@ -173,7 +174,8 @@ class DocumentController extends Document
|
|||
}
|
||||
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCount($document_srl, $point);
|
||||
$allow_same_ip = ($document_config->allow_vote_from_same_ip ?? 'N') === 'Y';
|
||||
$output = $this->updateVotedCount($document_srl, $point, $allow_same_ip);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
|
|
@ -1729,9 +1731,10 @@ class DocumentController extends Document
|
|||
* Increase the number of vote-up of the document
|
||||
* @param int $document_srl
|
||||
* @param int $point
|
||||
* @param bool $allow_same_ip
|
||||
* @return Object
|
||||
*/
|
||||
function updateVotedCount($document_srl, $point = 1)
|
||||
function updateVotedCount($document_srl, $point = 1, $allow_same_ip = false)
|
||||
{
|
||||
if($point > 0)
|
||||
{
|
||||
|
|
@ -1752,9 +1755,8 @@ class DocumentController extends Document
|
|||
$oDocument = DocumentModel::getDocument($document_srl, false, false);
|
||||
|
||||
// Pass if the author's IP address is as same as visitor's.
|
||||
if($oDocument->get('ipaddress') == \RX_CLIENT_IP)
|
||||
if(!$allow_same_ip && $oDocument->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
{
|
||||
$_SESSION['voted_document'][$document_srl] = false;
|
||||
return new BaseObject(-1, $failed_voted);
|
||||
}
|
||||
|
||||
|
|
@ -1908,9 +1910,11 @@ class DocumentController extends Document
|
|||
$oDocument = DocumentModel::getDocument($document_srl, false, false);
|
||||
|
||||
// Pass if the author's IP address is as same as visitor's.
|
||||
if($oDocument->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
$document_config = ModuleModel::getModulePartConfig('document', $module_srl);
|
||||
$allow_same_ip = ($document_config->allow_declare_from_same_ip ?? 'N') === 'Y';
|
||||
if(!$allow_same_ip && $oDocument->get('ipaddress') == \RX_CLIENT_IP && !$this->user->isAdmin())
|
||||
{
|
||||
$_SESSION['declared_document'][$document_srl] = false;
|
||||
return new BaseObject(-1, 'failed_declared');
|
||||
}
|
||||
|
||||
|
|
@ -1983,8 +1987,6 @@ class DocumentController extends Document
|
|||
|
||||
// Send message to admin
|
||||
$message_targets = array();
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
$document_config = ModuleModel::getModulePartConfig('document', $module_srl);
|
||||
if ($document_config->declared_message && in_array('admin', $document_config->declared_message))
|
||||
{
|
||||
$output = executeQueryArray('member.getAdmins', new stdClass);
|
||||
|
|
@ -3263,6 +3265,12 @@ Content;
|
|||
$document_config->use_vote_down = Context::get('use_vote_down');
|
||||
if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
|
||||
|
||||
$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_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->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);
|
||||
|
|
|
|||
|
|
@ -117,3 +117,5 @@ $lang->improper_document_reasons['pornography'] = 'Pornography.';
|
|||
$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_declare_from_same_ip = 'Allow reporting from same IP';
|
||||
|
|
|
|||
|
|
@ -117,3 +117,5 @@ $lang->improper_document_reasons['pornography'] = '음란물을 포함하고 있
|
|||
$lang->improper_document_reasons['privacy'] = '민감한 개인정보가 노출 되어있습니다.';
|
||||
$lang->improper_document_reasons['others'] = '기타(직접작성)';
|
||||
$lang->about_improper_document_declare = '게시글을 신고하신 이유를 간단히 적어서 제출해주시면 관리자 검토 후 조치하겠습니다.';
|
||||
$lang->allow_vote_from_same_ip = '동일 IP 추천 허용';
|
||||
$lang->allow_declare_from_same_ip = '동일 IP 신고 허용';
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="use_vote_up" class="x_control-label">{$lang->cmd_vote}</label>
|
||||
<label for="d_use_vote_up" class="x_control-label">{$lang->cmd_vote}</label>
|
||||
<div class="x_controls">
|
||||
<select name="use_vote_up" id="use_vote_up">
|
||||
<select name="use_vote_up" id="d_use_vote_up">
|
||||
<option value="Y" selected="selected"|cond="$document_config->use_vote_up=='Y'">{$lang->use}</option>
|
||||
<option value="S" selected="selected"|cond="$document_config->use_vote_up=='S'">{$lang->use_and_display}</option>
|
||||
<option value="N" selected="selected"|cond="$document_config->use_vote_up=='N'">{$lang->notuse}</option>
|
||||
|
|
@ -28,15 +28,41 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="use_vote_down" class="x_control-label">{$lang->cmd_vote_down}</label>
|
||||
<label for="d_use_vote_down" class="x_control-label">{$lang->cmd_vote_down}</label>
|
||||
<div class="x_controls">
|
||||
<select name="use_vote_down" id="use_vote_down">
|
||||
<select name="use_vote_down" id="d_use_vote_down">
|
||||
<option value="Y" selected="selected"|cond="$document_config->use_vote_down=='Y'">{$lang->use}</option>
|
||||
<option value="S" selected="selected"|cond="$document_config->use_vote_down=='S'">{$lang->use_and_display}</option>
|
||||
<option value="N" selected="selected"|cond="$document_config->use_vote_down=='N'">{$lang->notuse}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->allow_vote_from_same_ip}</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->allow_declare_from_same_ip}</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->cmd_declared_message}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue