Skip to content
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

Merged
merged 13 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/lang/lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3014,6 +3014,10 @@
<value xml:lang="vi"><![CDATA[Đã bình chọn.]]></value>
<value xml:lang="mn"><![CDATA[Санал болгогдсон]]></value>
</item>
<item name="success_voted_canceled">
<value xml:lang="ko"><![CDATA[추천이 취소되었습니다.]]></value>
<value xml:lang="en"><![CDATA[]]></value>
</item>
<item name="success_blamed">
<value xml:lang="ko"><![CDATA[비추천했습니다.]]></value>
<value xml:lang="en"><![CDATA[Not recommended successfully.]]></value>
Expand All @@ -3028,6 +3032,10 @@
<value xml:lang="vi"><![CDATA[Đã phê bình.]]></value>
<value xml:lang="mn"><![CDATA[Санал болгогдоогүй]]></value>
</item>
<item name="success_blamed_canceled">
<value xml:lang="ko"><![CDATA[비추천이 취소되었습니다.]]></value>
<value xml:lang="en"><![CDATA[]]></value>
</item>
<item name="success_copied">
<value xml:lang="ko"><![CDATA[복사했습니다.]]></value>
<value xml:lang="en"><![CDATA[Copied successfully.]]></value>
Expand Down
16 changes: 14 additions & 2 deletions modules/board/skins/xedition/_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1>
</li>
</ul>
<script>
var sTitle = '{str_ireplace(array('<script', '</script'), array("<scr'+'ipt", "</scr'+'ipt"), addslashes($oDocument->getTitleText()))}';
var sTitle = '{$oDocument->getTitleText()}';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 때문에 도저히.. ㅠㅠ 그냥 지워둬도 괜찮을것 같아요(SNS제목 띄울껀데 -0-.)

jQuery(function($){
$('.twitter').snspost({
type : 'twitter',
Expand All @@ -79,7 +79,19 @@ <h1>
content : sTitle
});
});
</script>
</script>
</div>
<div class="vote">
<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() > 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>
</li>
<li>
<a cond="$oDocument->getVoted() === false" 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() < 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>
</li>
</ul>
</div>
<div cond="$oDocument->hasUploadedFiles()" class="fileList">
<button type="button" class="toggleFile" onclick="jQuery(this).next('ul.files').toggle();"><i class="xi-diskette"></i> {$lang->uploaded_file} [<strong>{$oDocument->get('uploaded_count')}</strong>]</button>
Expand Down
7 changes: 7 additions & 0 deletions modules/board/skins/xedition/board.default.css
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,13 @@
.read_footer .sns a:hover{border-color:#DECA79;background-color:#f9dc5f;transition: all 0.2s ease-in-out;-webkit-transition: all 0.2s ease-in-out}
.read_footer .sns a:hover {color:#747474;transition: all 0.2s ease-in-out;-webkit-transition: all 0.2s ease-in-out}

.read_footer .vote{ margin-top:51px;text-align:center; }
.read_footer .vote li{display:inline;vertical-align:top}
.read_footer .vote a{display:inline-block;width:70px;height:70px;border:1px solid #e0e0e0;background-color:#f4f4f4; border-radius:2px;}
.read_footer .vote i{font-size:22px;line-height:45px;color:#bcbcbc}
.read_footer .vote a:hover{border-color:#DECA79;background-color:#f9dc5f;transition: all 0.2s ease-in-out;-webkit-transition: all 0.2s ease-in-out}
.read_footer .vote a:hover {color:#747474;transition: all 0.2s ease-in-out;-webkit-transition: all 0.2s ease-in-out}

.read_footer .sign {
clear: both;
border: 1px solid #ddd;
Expand Down
2 changes: 1 addition & 1 deletion modules/board/skins/xedition/skin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<author email_address="developers@xpressengine.com" link="https://www.xpressengine.com/">
<name xml:lang="ko">NAVER</name>
</author>
<license>LGPL v2</license>
<license>GPL v2</license>
<extra_vars>
</extra_vars>
</skin>
Expand Down
1 change: 1 addition & 0 deletions modules/document/conf/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<action name="getDocumentMenu" type="model" />

<action name="procDocumentVoteUp" type="controller" />
<action name="procDocumentVoteUpCancel" type="controller" />.
<action name="procDocumentVoteDown" type="controller" />
<action name="procDocumentDeclare" type="controller" />
<action name="procDocumentAddCart" type="controller" />
Expand Down
71 changes: 67 additions & 4 deletions modules/document/document.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기랑 아랫줄도 그냥 $point를 넣으면 됩니다.

$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;
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions modules/document/document.item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 조건식을 더 간단하게

if($_SESSION['voted_document'][$this->document_srl])
{
    return $_SESSION['voted_document'][$this->document_srl];
}

이렇게 하면 될 듯... (아래 391~398줄도 마찬가지)

Copy link
Member Author

Choose a reason for hiding this comment

The 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;
Expand Down
4 changes: 4 additions & 0 deletions modules/document/lang/lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@
<value xml:lang="ko"><![CDATA[최고관리자의 게시글을 지울 권한이 없습니다.]]></value>
<value xml:lang="en"><![CDATA[You don't have permission to delete the posts of Top Admin.]]></value>
</item>
<item name="msg_document_voted_cancel_not">
<value xml:lang="ko"><![CDATA[추천수가 0이하일 경우 추천캔슬을 사용할 수 없습니다.]]></value>
<value xml:lang="en"><![CDATA[]]></value>
</item>
<item name="move_target_module">
<value xml:lang="ko"><![CDATA[대상 페이지]]></value>
<value xml:lang="en"><![CDATA[Target module ]]></value>
Expand Down
1 change: 1 addition & 0 deletions modules/document/queries/deleteDocumentVotedLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
15 changes: 15 additions & 0 deletions modules/document/queries/getDocumentVotedLog.xml
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>