diff --git a/modules/board/skins/xedition/_comment.html b/modules/board/skins/xedition/_comment.html index 3830e0a11..fabb798c7 100644 --- a/modules/board/skins/xedition/_comment.html +++ b/modules/board/skins/xedition/_comment.html @@ -34,7 +34,10 @@
- {$lang->cmd_vote}:{$comment->get('voted_count')?$comment->get('voted_count'):0}
+ {$lang->cmd_vote}{$comment->get('voted_count')}
+ {$lang->cmd_vote}{$comment->get('voted_count')}
+ {$lang->cmd_vote_down}{$comment->get('blamed_count')}
+ {$lang->cmd_vote_down}{$comment->get('blamed_count')}
{$lang->cmd_reply}
{$lang->cmd_modify}
{$lang->cmd_delete}
diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php
index 7204a8bf2..997f7c091 100644
--- a/modules/comment/comment.controller.php
+++ b/modules/comment/comment.controller.php
@@ -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)
diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php
index ea4076962..397645051 100644
--- a/modules/comment/comment.item.php
+++ b/modules/comment/comment.item.php
@@ -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
diff --git a/modules/comment/conf/module.xml b/modules/comment/conf/module.xml
index 960344c37..d13854c26 100644
--- a/modules/comment/conf/module.xml
+++ b/modules/comment/conf/module.xml
@@ -23,6 +23,8 @@