-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
추천/비추천/추천삭제 기능추가. #140
추천/비추천/추천삭제 기능추가. #140
Changes from 7 commits
9241357
6a2dc54
19a32d1
1ba633f
43a6cae
31ea80a
d3d7031
84d2c3b
5093d25
4a0efef
d641e2c
c2b78f4
6f1066d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,37 @@ function procDocumentVoteUp() | |
return $output; | ||
} | ||
|
||
function procDocumentVoteUpCancel() | ||
{ | ||
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); | ||
|
||
$document_srl = Context::get('target_srl'); | ||
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); | ||
|
||
$oDocumentModel = getModel('document'); | ||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false); | ||
if($oDocument->get('voted_count') <= 0) | ||
{ | ||
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 = new Object(); | ||
$output->setMessage('success_voted_canceled'); | ||
return $output; | ||
} | ||
|
||
/** | ||
* insert alias | ||
* @param int $module_srl | ||
|
@@ -89,6 +120,37 @@ function procDocumentVoteDown() | |
return $output; | ||
} | ||
|
||
function procDocumentVoteDownCancel() | ||
{ | ||
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); | ||
|
||
$document_srl = Context::get('target_srl'); | ||
if(!$document_srl) return new Object(-1, 'msg_invalid_request'); | ||
|
||
$oDocumentModel = getModel('document'); | ||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false); | ||
if($oDocument->get('blamed_count') >= 0) | ||
{ | ||
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->blamed_count = $oDocument->get('blamed_count') + 1; | ||
$output = executeQuery('document.updateBlamedCount', $args); | ||
$d_output = executeQuery('document.deleteDocumentVotedLog', $d_args); | ||
|
||
//session reset | ||
$_SESSION['voted_document'][$document_srl] = false; | ||
|
||
$output = new Object(); | ||
$output->setMessage('success_blamed_canceled'); | ||
return $output; | ||
} | ||
|
||
/** | ||
* Action called when the post is reported by other member | ||
* @return void|Object | ||
|
@@ -1175,7 +1237,7 @@ function updateVotedCount($document_srl, $point = 1) | |
} | ||
|
||
// 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; | ||
|
@@ -1201,11 +1263,15 @@ function updateVotedCount($document_srl, $point = 1) | |
if($point < 0) | ||
{ | ||
$args->blamed_count = $oDocument->get('blamed_count') + $point; | ||
// Leave in the session information | ||
$_SESSION['voted_document'][$document_srl] = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기랑 아랫줄도 그냥 |
||
$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; | ||
|
@@ -1239,9 +1305,6 @@ function updateVotedCount($document_srl, $point = 1) | |
$oCacheHandler->delete($cache_key); | ||
} | ||
|
||
// Leave in the session information | ||
$_SESSION['voted_document'][$document_srl] = true; | ||
|
||
// Return result | ||
$output = new Object(); | ||
if($point > 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,6 +369,37 @@ function getTitleText($cut_size = 0, $tail='...') | |
return $title; | ||
} | ||
|
||
function getVoted() | ||
{ | ||
if(!$this->document_srl) return; | ||
if($_SESSION['voted_document'][$this->document_srl] == '1') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 조건식을 더 간단하게
이렇게 하면 될 듯... (아래 391~398줄도 마찬가지) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어.... 나에겐 왜 이런 머리가 없는거지 |
||
{ | ||
return 1; | ||
} | ||
else if($_SESSION['voted_document'][$this->document_srl] == '-1') | ||
{ | ||
return -1; | ||
} | ||
|
||
$logged_info = Context::get('logged_info'); | ||
|
||
$args = new stdClass(); | ||
$args->member_srl = $logged_info->member_srl; | ||
$args->document_srl = $this->document_srl; | ||
$output = executeQuery('document.getDocumentVotedLog', $args); | ||
|
||
if($output->data->point === '1') | ||
{ | ||
return 1; | ||
} | ||
else if($output->data->point === '-1') | ||
{ | ||
return -1; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function getTitle($cut_size = 0, $tail='...') | ||
{ | ||
if(!$this->document_srl) return; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 때문에 도저히.. ㅠㅠ 그냥 지워둬도 괜찮을것 같아요(SNS제목 띄울껀데 -0-.)