mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
댓글에 대해서도 추천, 비추천
This commit is contained in:
parent
c2b78f4468
commit
6f1066d3b9
9 changed files with 150 additions and 5 deletions
|
|
@ -34,7 +34,10 @@
|
|||
</ul>
|
||||
</div>
|
||||
<p class="action">
|
||||
<span class="vote" cond="$comment->get('voted_count')!=0">{$lang->cmd_vote}:{$comment->get('voted_count')?$comment->get('voted_count'):0}</span>
|
||||
<a cond="$comment->getVote() === false || $comment->getVote() < 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteUp','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote}{$comment->get('voted_count')}</a>
|
||||
<a cond="$comment->getVote() > 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteUpCancel','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote}{$comment->get('voted_count')}</a>
|
||||
<a cond="$comment->getVote() === false || $comment->getVote() > 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteDown','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote_down}{$comment->get('blamed_count')}</a>
|
||||
<a cond="$comment->getVote() < 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteDownCancel','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote_down}{$comment->get('blamed_count')}</a>
|
||||
<a cond="$oDocument->allowComment()" href="{getUrl('act','dispBoardReplyComment','comment_srl',$comment->comment_srl)}" class="reply"><i class="xi-reply"></i> {$lang->cmd_reply}</a>
|
||||
<a cond="$comment->isGranted()||!$comment->get('member_srl')" href="{getUrl('act','dispBoardModifyComment','comment_srl',$comment->comment_srl)}" class="modify"><i class="xi-eraser"></i> {$lang->cmd_modify}</a>
|
||||
<a cond="$comment->isGranted()||!$comment->get('member_srl')" href="{getUrl('act','dispBoardDeleteComment','comment_srl',$comment->comment_srl)}" class="delete"><i class="xi-trash"></i> {$lang->cmd_delete}</a>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,29 @@ class commentController extends comment
|
|||
return $output;
|
||||
}
|
||||
|
||||
function procCommentVoteUpCancel()
|
||||
{
|
||||
if(!Context::get('logged_info')) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$comment_srl = Context::get('target_srl');
|
||||
if(!$comment_srl) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$oCommentModel = getModel('comment');
|
||||
$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
|
||||
if($oComment->get('voted_count') <= 0)
|
||||
{
|
||||
return new Object(-1, 'msg_comment_voted_cancel_not');
|
||||
}
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCountCancel($comment_srl, $oComment, $point);
|
||||
|
||||
$output = new Object();
|
||||
$output->setMessage('success_voted_canceled');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action to handle recommendation votes on comments (Down)
|
||||
* @return Object
|
||||
|
|
@ -97,6 +120,74 @@ class commentController extends comment
|
|||
return $output;
|
||||
}
|
||||
|
||||
function procCommentVoteDownCancel()
|
||||
{
|
||||
if(!Context::get('logged_info')) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$comment_srl = Context::get('target_srl');
|
||||
if(!$comment_srl) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$oCommentModel = getModel('comment');
|
||||
$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
|
||||
if($oComment->get('blamed_count') >= 0)
|
||||
{
|
||||
return new Object(-1, 'msg_comment_blamed_cancel_not');
|
||||
}
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCountCancel($comment_srl, $oComment, $point);
|
||||
|
||||
$output = new Object();
|
||||
$output->setMessage('success_voted_canceled');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function updateVotedCountCancel($comment_srl, $oComment, $point)
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
$args = new stdClass();
|
||||
$d_args = new stdClass();
|
||||
$args->comment_srl = $d_args->comment_srl = $comment_srl;
|
||||
$d_args->member_srl = $logged_info->member_srl;
|
||||
if($point > 0)
|
||||
{
|
||||
$args->voted_count = $oComment->get('voted_count') - $point;
|
||||
$output = executeQuery('comment.updateVotedCount', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->blamed_count = $oComment->get('blamed_count') - $point;
|
||||
$output = executeQuery('comment.updateBlamedCount', $args);
|
||||
}
|
||||
$d_output = executeQuery('comment.deleteCommentVotedLog', $d_args);
|
||||
if(!$d_output->toBool()) return $d_output;
|
||||
|
||||
//session reset
|
||||
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||
|
||||
// begin transaction
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->member_srl = $oComment->get('member_srl');
|
||||
$obj->module_srl = $oComment->get('module_srl');
|
||||
$obj->comment_srl = $oComment->get('comment_srl');
|
||||
$obj->update_target = ($point < 0) ? 'blamed_count' : 'voted_count';
|
||||
$obj->point = $point;
|
||||
$obj->before_point = ($point < 0) ? $oComment->get('blamed_count') : $oComment->get('voted_count');
|
||||
$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
|
||||
$obj->cancel = 1;
|
||||
$trigger_output = ModuleHandler::triggerCall('comment.updateVotedCountCancel', 'after', $obj);
|
||||
if(!$trigger_output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $trigger_output;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to be called when a comment posting is reported
|
||||
* @return void|Object
|
||||
|
|
@ -1163,11 +1254,14 @@ class commentController extends comment
|
|||
// update the number of votes
|
||||
if($point < 0)
|
||||
{
|
||||
// leave into session information
|
||||
$_SESSION['voted_comment'][$comment_srl] = $point;
|
||||
$args->blamed_count = $oComment->get('blamed_count') + $point;
|
||||
$output = executeQuery('comment.updateBlamedCount', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['voted_comment'][$comment_srl] = $point;
|
||||
$args->voted_count = $oComment->get('voted_count') + $point;
|
||||
$output = executeQuery('comment.updateVotedCount', $args);
|
||||
}
|
||||
|
|
@ -1193,9 +1287,6 @@ class commentController extends comment
|
|||
|
||||
$oDB->commit();
|
||||
|
||||
// leave into session information
|
||||
$_SESSION['voted_comment'][$comment_srl] = TRUE;
|
||||
|
||||
// Return the result
|
||||
$output = new Object(0, $success_message);
|
||||
if($point > 0)
|
||||
|
|
|
|||
|
|
@ -281,6 +281,29 @@ class commentItem extends Object
|
|||
return htmlspecialchars($this->get('nick_name'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
}
|
||||
|
||||
function getVote()
|
||||
{
|
||||
if(!$this->comment_srl) return false;
|
||||
if($_SESSION['voted_comment'][$this->comment_srl])
|
||||
{
|
||||
return $_SESSION['voted_comment'][$this->comment_srl];
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
$args = new stdClass();
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
$args->comment_srl = $this->comment_srl;
|
||||
$output = executeQuery('comment.getCommentVotedLog', $args);
|
||||
|
||||
if($output->data->point)
|
||||
{
|
||||
return $output->data->point;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return content with htmlspecialchars
|
||||
* @return string
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
<action name="procCommentAdminAddCart" type="controller" />
|
||||
<action name="procCommentGetList" type="controller" />
|
||||
<action name="procCommentAdminMoveToTrash" type="controller" />
|
||||
<action name="procCommentVoteUpCancel" type="controller" />
|
||||
<action name="procCommentVoteDownCancel" type="controller" />
|
||||
</actions>
|
||||
<menus>
|
||||
<menu name="comment">
|
||||
|
|
|
|||
|
|
@ -81,6 +81,12 @@
|
|||
<value xml:lang="tr"><![CDATA[Yorumları, kullanıcının girdiği rakam kadar gösterin. Eğer yorum sayısı belirlenen sayıyı aşarsa, yorum Liste'ye taşınır.]]></value>
|
||||
<value xml:lang="vi"><![CDATA[Hiển thị số bình luận được gửi, và nó sẽ tạo một danh sách nếu có nhiều bình luận.]]></value>
|
||||
</item>
|
||||
<item name="msg_comment_voted_cancel_not">
|
||||
<value xml:lang="ko"><![CDATA[추천수가 0이하일 경우 추천캔슬을 사용할 수 없습니다.]]></value>
|
||||
</item>
|
||||
<item name="msg_comment_blamed_cancel_not">
|
||||
<value xml:lang="ko"><![CDATA[추천수가 0이하일 경우 비추천캔슬을 사용할 수 없습니다.]]></value>
|
||||
</item>
|
||||
<item name="msg_cart_is_null">
|
||||
<value xml:lang="ko"><![CDATA[삭제할 글을 선택해주세요.]]></value>
|
||||
<value xml:lang="en"><![CDATA[Please select an article to delete.]]></value>
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@
|
|||
</tables>
|
||||
<conditions>
|
||||
<condition operation="in" column="comment_srl" var="comment_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
15
modules/comment/queries/getCommentVotedLog.xml
Normal file
15
modules/comment/queries/getCommentVotedLog.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<query id="getCommentVotedLog" action="select">
|
||||
<tables>
|
||||
<table name="comment_voted_log" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="comment_srl" var="comment_srl" filter="number" notnull="notnull" />
|
||||
<group pipe="and">
|
||||
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" pipe="and" />
|
||||
</group>
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -162,6 +162,10 @@ class documentController extends document
|
|||
//session reset
|
||||
$_SESSION['voted_document'][$document_srl] = false;
|
||||
|
||||
// begin transaction
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->member_srl = $oDocument->get('member_srl');
|
||||
$obj->module_srl = $oDocument->get('module_srl');
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ class documentItem extends Object
|
|||
|
||||
function getVoted()
|
||||
{
|
||||
if(!$this->document_srl) return;
|
||||
if(!$this->document_srl) return false;
|
||||
if($_SESSION['voted_document'][$this->document_srl])
|
||||
{
|
||||
return $_SESSION['voted_document'][$this->document_srl];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue