mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 17:44:38 +09:00
Fix multiple queries for document/comment vote count
This commit is contained in:
parent
4f821bca85
commit
c227d188a7
6 changed files with 62 additions and 12 deletions
|
|
@ -1227,7 +1227,7 @@ class commentController extends comment
|
||||||
// invalid vote if both ip addresses between author's and the current user are same.
|
// invalid vote if both ip addresses between author's and the current user are same.
|
||||||
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
||||||
{
|
{
|
||||||
$_SESSION['voted_comment'][$comment_srl] = TRUE;
|
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1241,7 +1241,7 @@ class commentController extends comment
|
||||||
// session registered if the author information matches to the current logged-in user's.
|
// session registered if the author information matches to the current logged-in user's.
|
||||||
if($member_srl && $member_srl == $oComment->get('member_srl'))
|
if($member_srl && $member_srl == $oComment->get('member_srl'))
|
||||||
{
|
{
|
||||||
$_SESSION['voted_comment'][$comment_srl] = TRUE;
|
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1264,7 +1264,7 @@ class commentController extends comment
|
||||||
// session registered if log info contains recommendation vote log.
|
// session registered if log info contains recommendation vote log.
|
||||||
if($output->data->count)
|
if($output->data->count)
|
||||||
{
|
{
|
||||||
$_SESSION['voted_comment'][$comment_srl] = TRUE;
|
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,12 +284,13 @@ class commentItem extends Object
|
||||||
function getVote()
|
function getVote()
|
||||||
{
|
{
|
||||||
if(!$this->comment_srl) return false;
|
if(!$this->comment_srl) return false;
|
||||||
if($_SESSION['voted_comment'][$this->comment_srl])
|
if(isset($_SESSION['voted_comment'][$this->comment_srl]))
|
||||||
{
|
{
|
||||||
return $_SESSION['voted_comment'][$this->comment_srl];
|
return $_SESSION['voted_comment'][$this->comment_srl];
|
||||||
}
|
}
|
||||||
|
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
if(!$logged_info->member_srl) return false;
|
||||||
|
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->member_srl = $logged_info->member_srl;
|
$args->member_srl = $logged_info->member_srl;
|
||||||
|
|
@ -298,10 +299,10 @@ class commentItem extends Object
|
||||||
|
|
||||||
if($output->data->point)
|
if($output->data->point)
|
||||||
{
|
{
|
||||||
return $output->data->point;
|
return $_SESSION['voted_comment'][$this->comment_srl] = $output->data->point;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $_SESSION['voted_comment'][$this->comment_srl] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
13
modules/comment/queries/getCommentVotedLogMulti.xml
Normal file
13
modules/comment/queries/getCommentVotedLogMulti.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<query id="getCommentVotedLog" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="comment_voted_log" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="comment_srl" />
|
||||||
|
<column name="point" />
|
||||||
|
</columns>
|
||||||
|
<conditions>
|
||||||
|
<condition operation="in" column="comment_srl" var="comment_srls" filter="number" notnull="notnull" />
|
||||||
|
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
|
||||||
|
</conditions>
|
||||||
|
</query>
|
||||||
|
|
@ -1325,7 +1325,7 @@ class documentController extends document
|
||||||
// Pass if the author's IP address is as same as visitor's.
|
// Pass if the author's IP address is as same as visitor's.
|
||||||
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
||||||
{
|
{
|
||||||
$_SESSION['voted_document'][$document_srl] = true;
|
$_SESSION['voted_document'][$document_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1339,7 +1339,7 @@ class documentController extends document
|
||||||
// Pass after registering a session if author's information is same as the currently logged-in user's.
|
// Pass after registering a session if author's information is same as the currently logged-in user's.
|
||||||
if($member_srl && $member_srl == $oDocument->get('member_srl'))
|
if($member_srl && $member_srl == $oDocument->get('member_srl'))
|
||||||
{
|
{
|
||||||
$_SESSION['voted_document'][$document_srl] = true;
|
$_SESSION['voted_document'][$document_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1359,7 +1359,7 @@ class documentController extends document
|
||||||
// Pass after registering a session if log information has vote-up logs
|
// Pass after registering a session if log information has vote-up logs
|
||||||
if($output->data->count)
|
if($output->data->count)
|
||||||
{
|
{
|
||||||
$_SESSION['voted_document'][$document_srl] = true;
|
$_SESSION['voted_document'][$document_srl] = false;
|
||||||
return new Object(-1, $failed_voted);
|
return new Object(-1, $failed_voted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -375,12 +375,13 @@ class documentItem extends Object
|
||||||
function getVoted()
|
function getVoted()
|
||||||
{
|
{
|
||||||
if(!$this->document_srl) return false;
|
if(!$this->document_srl) return false;
|
||||||
if($_SESSION['voted_document'][$this->document_srl])
|
if(isset($_SESSION['voted_document'][$this->document_srl]))
|
||||||
{
|
{
|
||||||
return $_SESSION['voted_document'][$this->document_srl];
|
return $_SESSION['voted_document'][$this->document_srl];
|
||||||
}
|
}
|
||||||
|
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
if(!$logged_info->member_srl) return false;
|
||||||
|
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->member_srl = $logged_info->member_srl;
|
$args->member_srl = $logged_info->member_srl;
|
||||||
|
|
@ -389,10 +390,10 @@ class documentItem extends Object
|
||||||
|
|
||||||
if($output->data->point)
|
if($output->data->point)
|
||||||
{
|
{
|
||||||
return $output->data->point;
|
return $_SESSION['voted_document'][$this->document_srl] = $output->data->point;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $_SESSION['voted_document'][$this->document_srl] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTitle($cut_size = 0, $tail='...')
|
function getTitle($cut_size = 0, $tail='...')
|
||||||
|
|
@ -764,6 +765,7 @@ class documentItem extends Object
|
||||||
$oCommentModel = getModel('comment');
|
$oCommentModel = getModel('comment');
|
||||||
$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
|
$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
|
||||||
if(!$output->toBool() || !count($output->data)) return;
|
if(!$output->toBool() || !count($output->data)) return;
|
||||||
|
|
||||||
// Create commentItem object from a comment list
|
// Create commentItem object from a comment list
|
||||||
// If admin priviledge is granted on parent posts, you can read its child posts.
|
// If admin priviledge is granted on parent posts, you can read its child posts.
|
||||||
$accessible = array();
|
$accessible = array();
|
||||||
|
|
@ -785,6 +787,39 @@ class documentItem extends Object
|
||||||
}
|
}
|
||||||
$comment_list[$val->comment_srl] = $oCommentItem;
|
$comment_list[$val->comment_srl] = $oCommentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache the vote log for all comments.
|
||||||
|
$logged_info = Context::get('logged_info');
|
||||||
|
if ($logged_info->member_srl)
|
||||||
|
{
|
||||||
|
$comment_srls = array();
|
||||||
|
foreach ($comment_list as $comment_srl => $comment)
|
||||||
|
{
|
||||||
|
if (!isset($_SESSION['voted_comment'][$comment_srl]))
|
||||||
|
{
|
||||||
|
$comment_srls[] = $comment_srl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($comment_srls))
|
||||||
|
{
|
||||||
|
$output = executeQuery('comment.getCommentVotedLogMulti', (object)array(
|
||||||
|
'comment_srls' => $comment_srls,
|
||||||
|
'member_srl' => $logged_info->member_srl,
|
||||||
|
));
|
||||||
|
foreach ($output->data as $data)
|
||||||
|
{
|
||||||
|
$_SESSION['voted_comment'][$data->comment_srl] = $data->point;
|
||||||
|
}
|
||||||
|
foreach ($comment_srls as $comment_srl)
|
||||||
|
{
|
||||||
|
if (!isset($_SESSION['voted_comment'][$comment_srl]))
|
||||||
|
{
|
||||||
|
$_SESSION['voted_comment'][$comment_srl] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Variable setting to be displayed on the skin
|
// Variable setting to be displayed on the skin
|
||||||
Context::set($cpageStr, $output->page_navigation->cur_page);
|
Context::set($cpageStr, $output->page_navigation->cur_page);
|
||||||
Context::set('cpage', $output->page_navigation->cur_page);
|
Context::set('cpage', $output->page_navigation->cur_page);
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ class layout extends ModuleObject
|
||||||
$args->layout = implode('|@|', $layout_path);
|
$args->layout = implode('|@|', $layout_path);
|
||||||
$args->layout_srl = $layout->layout_srl;
|
$args->layout_srl = $layout->layout_srl;
|
||||||
$output = executeQuery('layout.updateLayout', $args);
|
$output = executeQuery('layout.updateLayout', $args);
|
||||||
|
Rhymix\Framework\Cache::delete('layout:' . $args->layout_srl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue