improve dont sign in user also can vote

This commit is contained in:
BJRambo 2017-01-14 14:45:56 +09:00
parent ac8a5338cb
commit 884ecbd02e
2 changed files with 4 additions and 15 deletions

View file

@ -84,12 +84,12 @@
<div class="vote"> <div class="vote">
<ul> <ul>
<li> <li>
<a cond="$oDocument->getVoted() === false || $oDocument->getVoted() < 0" 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 || $oDocument->getVoted() < 0" href="#" onclick="doCallModuleAction('document','procDocumentVoteUp','{$oDocument->document_srl}');return false;" class="voted"> <i class="xi-thumbs-up"></i><br>{$lang->cmd_vote} {$oDocument->get('voted_count')}</a>
<a cond="$oDocument->getVoted() > 0" 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() > 0" href="#" onclick="doCallModuleAction('document','procDocumentVoteUpCancel','{$oDocument->document_srl}');return false;" class="voted"> <i class="xi-thumbs-up"></i><br>{$lang->cmd_vote} {$oDocument->get('voted_count')}</a>
</li> </li>
<li> <li>
<a cond="$oDocument->getVoted() === false || $oDocument->getVoted() > 0" herf="#" onclick="doCallModuleAction('document','procDocumentVoteDown','{$oDocument->document_srl}');return false;"|cond="$is_logged" class="voted"> <i class="xi-thumbs-down"></i><br>{$lang->cmd_vote_down} {$oDocument->get('blamed_count')}</a> <a cond="$oDocument->getVoted() === false || $oDocument->getVoted() > 0" herf="#" onclick="doCallModuleAction('document','procDocumentVoteDown','{$oDocument->document_srl}');return false;" class="voted"> <i class="xi-thumbs-down"></i><br>{$lang->cmd_vote_down} {$oDocument->get('blamed_count')}</a>
<a cond="$oDocument->getVoted() < 0" herf="#" onclick="doCallModuleAction('document','procDocumentVoteDownCancel','{$oDocument->document_srl}');return false;"|cond="$is_logged" class="voted"> <i class="xi-thumbs-down"></i><br>{$lang->cmd_vote_down} {$oDocument->get('blamed_count')}</a> <a cond="$oDocument->getVoted() < 0" herf="#" onclick="doCallModuleAction('document','procDocumentVoteDownCancel','{$oDocument->document_srl}');return false;" class="voted"> <i class="xi-thumbs-down"></i><br>{$lang->cmd_vote_down} {$oDocument->get('blamed_count')}</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -24,8 +24,6 @@ class documentController extends document
*/ */
function procDocumentVoteUp() function procDocumentVoteUp()
{ {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
$document_srl = Context::get('target_srl'); $document_srl = Context::get('target_srl');
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); if(!$document_srl) return new Object(-1, 'msg_invalid_request');
@ -46,8 +44,6 @@ class documentController extends document
function procDocumentVoteUpCancel() function procDocumentVoteUpCancel()
{ {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
$document_srl = Context::get('target_srl'); $document_srl = Context::get('target_srl');
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); if(!$document_srl) return new Object(-1, 'msg_invalid_request');
@ -90,8 +86,6 @@ class documentController extends document
*/ */
function procDocumentVoteDown() function procDocumentVoteDown()
{ {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
$document_srl = Context::get('target_srl'); $document_srl = Context::get('target_srl');
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); if(!$document_srl) return new Object(-1, 'msg_invalid_request');
@ -112,8 +106,6 @@ class documentController extends document
function procDocumentVoteDownCancel() function procDocumentVoteDownCancel()
{ {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
$document_srl = Context::get('target_srl'); $document_srl = Context::get('target_srl');
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); if(!$document_srl) return new Object(-1, 'msg_invalid_request');
@ -1311,7 +1303,6 @@ class documentController extends document
$_SESSION['voted_document'][$document_srl] = false; $_SESSION['voted_document'][$document_srl] = false;
return new Object(-1, $failed_voted); return new Object(-1, $failed_voted);
} }
// Create a member model object // Create a member model object
$oMemberModel = getModel('member'); $oMemberModel = getModel('member');
$member_srl = $oMemberModel->getLoggedMemberSrl(); $member_srl = $oMemberModel->getLoggedMemberSrl();
@ -1326,7 +1317,6 @@ class documentController extends document
return new Object(-1, $failed_voted); return new Object(-1, $failed_voted);
} }
} }
// Use member_srl for logged-in members and IP address for non-members. // Use member_srl for logged-in members and IP address for non-members.
$args = new stdClass(); $args = new stdClass();
if($member_srl) if($member_srl)
@ -1345,7 +1335,6 @@ class documentController extends document
$_SESSION['voted_document'][$document_srl] = false; $_SESSION['voted_document'][$document_srl] = false;
return new Object(-1, $failed_voted); return new Object(-1, $failed_voted);
} }
// begin transaction // begin transaction
$oDB = DB::getInstance(); $oDB = DB::getInstance();
$oDB->begin(); $oDB->begin();