추천/비추천 인식 방법을 변경하고 그에 맞게 코드 변경

This commit is contained in:
qw5414 2016-01-22 13:07:22 +09:00
parent 1ba633ff83
commit 43a6caeb36
5 changed files with 42 additions and 12 deletions

View file

@ -85,7 +85,7 @@
<ul>
<li>
<a cond="$oDocument->getVoted() === false" href="#" onclick="doCallModuleAction('document','procDocumentVoteUp','{$oDocument->document_srl}');return false;"|cond="$is_logged" class="voted"> <i class="xi-thumbs-up"></i><br>{$lang->cmd_vote} {$oDocument->get('voted_count')}</a>
<a cond="$oDocument->getVoted() !== false" href="#" onclick="doCallModuleAction('document','procDocumentVoteUpCancel','{$oDocument->document_srl}');return false;"|cond="$is_logged" class="voted"> <i class="xi-thumbs-up"></i><br>{$lang->cmd_vote} {$oDocument->get('voted_count')}</a>
<a cond="$oDocument->getVoted() === 'voted'" href="#" onclick="doCallModuleAction('document','procDocumentVoteUpCancel','{$oDocument->document_srl}');return false;"|cond="$is_logged" class="voted"> <i class="xi-thumbs-up"></i><br>{$lang->cmd_vote} {$oDocument->get('voted_count')}</a>
</li>
</ul>
</div>

View file

@ -57,15 +57,18 @@ class documentController extends document
{
return new Object(-1, 'msg_document_voted_cancel_not');
}
$logged_info = Context::get('logged_info');
$args = new stdClass();
$d_args = new stdClass();
$args->document_srl = $d_args->document_srl = $document_srl;
$d_args->member_srl = $logged_info->member_srl;
$args->voted_count = $oDocument->get('voted_count') - 1;
$output = executeQuery('document.updateVotedCount', $args);
$d_output = executeQuery('document.deleteDocumentVotedLog', $d_args);
//session reset
$_SESSION['voted_document'][$document_srl] = false;
$output->setMessage('success_voted_canceled');
return $output;
}
@ -1201,7 +1204,7 @@ class documentController extends document
}
// Use member_srl for logged-in members and IP address for non-members.
$args = new stdClass;
$args = new stdClass();
if($member_srl)
{
$args->member_srl = $member_srl;
@ -1227,11 +1230,15 @@ class documentController extends document
if($point < 0)
{
$args->blamed_count = $oDocument->get('blamed_count') + $point;
// Leave in the session information
$_SESSION['voted_document'][$document_srl] = -1;
$output = executeQuery('document.updateBlamedCount', $args);
}
else
{
$args->voted_count = $oDocument->get('voted_count') + $point;
// Leave in the session information
$_SESSION['voted_document'][$document_srl] = 1;
$output = executeQuery('document.updateVotedCount', $args);
}
if(!$output->toBool()) return $output;
@ -1265,9 +1272,6 @@ class documentController extends document
$oCacheHandler->delete($cache_key);
}
// Leave in the session information
$_SESSION['voted_document'][$document_srl] = true;
// Return result
$output = new Object();
if($point > 0)

View file

@ -372,19 +372,29 @@ class documentItem extends Object
function getVoted()
{
if(!$this->document_srl) return;
if($_SESSION['voted_document'][$this->document_srl] == '1')
{
return 'voted';
}
else if($_SESSION['voted_document'][$this->document_srl] == '-1')
{
return 'blamed';
}
$logged_info = Context::get('logged_info');
$member_srl = $logged_info->member_srl;
$document_srl = $this->document_srl;
$args = new stdClass();
$args->member_srl = $member_srl;
$args->document_srl = $document_srl;
$output = executeQuery('document.getDocumentVotedLogInfo', $args);
$args->member_srl = $logged_info->member_srl;
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocumentVotedLog', $args);
if($output->data->count)
if($output->data->point === '1')
{
return true;
return 'voted';
}
else if($output->data->point === '-1')
{
return 'blamed';
}
return false;

View file

@ -4,5 +4,6 @@
</tables>
<conditions>
<condition operation="in" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,15 @@
<query id="getDocumentVotedLog" action="select">
<tables>
<table name="document_voted_log" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_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>